List := FQueue.LockList;
for I := 0 to List.Count - 1 do
begin
Mail := TIdMessageTaskman(List[I]);
FEventLogger.LogMessage( 'Mail' + Mail.ToString, EVENTLOG_INFORMATION_TYPE , 0, 2);
try
try
FidSmtp.Connect();
FidSmtp.Send(Mail);
except
on e: exception do
begin
FEventLogger.LogMessage('Error sending mail ' + e.ClassName + ', ' +
e.Message, EVENTLOG_ERROR_TYPE, 0, 2);
MarkMailExecution(Mail.TaskID, Mail.NotificationID, False, e.Message);
Continue;
end;
end;
finally
begin
if FidSmtp.Connected then
FidSmtp.Disconnect;
end;
end;
FEventLogger.LogMessage( 'after finally', EVENTLOG_INFORMATION_TYPE , 0, 2);
MarkMailExecution(Mail.TaskID, Mail.NotificationID, True, '');
FreeAndNil(Mail)
ดังนั้นโค้ดต่อไปนี้จึงใช้งานได้ แต่ทันทีที่มีปัญหาในการส่งอีเมลและมีข้อยกเว้นเกิดขึ้น บริการจะหยุดลง มีวิธีที่ฉันสามารถทำให้มันดำเนินต่อไปและผ่านคิวทั้งหมดได้หรือไม่? แม้ว่าจะมีข้อความผิดพลาดก็ตาม ตัวอย่างข้อผิดพลาดที่ทำให้บริการของฉันหยุดทำงานคือเมื่อ "ฉันแนบ" ไฟล์ที่ไม่มีอยู่
finally
อาจส่งข้อยกเว้น หรือแม้แต่ส่วนexcept
- person kobik   schedule 21.07.2015on E: ESpecifcException do
(คุณสามารถมีหลายรายการในบล็อก ยกเว้น) - person Disillusioned   schedule 21.07.2015