Program lock-up when using Synapse to send an email lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- oldcoder · 2016-06-07 14:22 I am trying to learn how to use Synapse to send my invoices out by email and it's all working, but when I hit the send button the whole program locks up for the 10-15 seconds it takes to send the email and get back a 'success' response. The code I am using is pretty much taken from examples found online:   begin     m:=TMimemess.create;     try       p := m.AddPartMultipart('mixed', nil);       m.AddPartText(invemailtextlines.lines,p);       m.AddPartBinaryFromFile('C:\......\Invoice 1.pdf',p);       m.header.from:=invemailfromadd;       m.header.tolist.add(invemailtoadd);       m.header.subject:=invemailsubject;       m.EncodeMessage;       B := SendToRaw(invemailfromadd, invemailtoadd, smtpserver+':'+smtpport, m.lines, smtpusername, smtppass);       if not B then         ShowMessage('Could not send the message!')       else         ShowMessage('Message sent successfully.');     finally       m.free;     end;   end;  Can anyone tell me if there is a way to stop the program locking up while the email is sending? Thanks. ---------------------------------------------------------------------- molly · 2016-06-07 15:48 QuoteCan anyone tell me if there is a way to stop the program locking up while the email is sending? In case ou want to keep your gui responsive there are several paths you could take. - threads or parallel procedures - using a timer - asynchronous calls ---------------------------------------------------------------------- oldcoder · 2016-06-24 10:37 Thanks for replying Molly. Ive been trying to use threads but still haven't managed to crack the problem ---------------------------------------------------------------------- rvk · 2016-06-24 10:49 Quote from: oldcoder on June 24, 2016, 12:37:58 pmThanks for replying Molly. Ive been trying to use threads but still haven't managed to crack the problem Then you need to show the code of the thread. How large is the PDF you attached? I find 10-15 seconds a lot for just sending a small mail. (or your mailserver is not that fast) How long does it take to send the same mail in your mail-program (and in that case you need to look at the bottom right or open up the detail-screen to see how long it really takes to transfer the mail to the smtp server).