瀏覽代碼

Quick.SMTP small fixes

Exilon 7 年之前
父節點
當前提交
574f0b2685
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      Quick.SMTP.pas

+ 7 - 2
Quick.SMTP.pas

@@ -163,6 +163,7 @@ var
   email : string;
   email : string;
   filename : string;
   filename : string;
   mBody : TIdText;
   mBody : TIdText;
+  idattach : TIdAttachmentFile;
 begin
 begin
   Result := False;
   Result := False;
   SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
   SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
@@ -191,7 +192,7 @@ begin
       begin
       begin
         for filename in fMail.Attachments do
         for filename in fMail.Attachments do
         begin
         begin
-          TIdAttachmentFile.Create(msg.MessageParts,filename);
+          idattach := TIdAttachmentFile.Create(msg.MessageParts,filename);
         end;
         end;
       end;
       end;
 
 
@@ -227,10 +228,14 @@ begin
         on E : Exception do raise Exception.Create(Format('[%s] : %s',[Self.ClassName,e.Message]));
         on E : Exception do raise Exception.Create(Format('[%s] : %s',[Self.ClassName,e.Message]));
       end;
       end;
     finally
     finally
+      if Assigned(msg.MessageParts) then msg.MessageParts.Free;
+      if Assigned(mBody) then mBody.Free;
+      if Assigned(idattach) then idattach.Free;
+
       msg.Free;
       msg.Free;
     end;
     end;
   finally
   finally
-    if Assigned(SSLHandler) then SSLHandler.Free;
+    SSLHandler.Free;
   end;
   end;
 end;
 end;