bruno-pere Posted March 1, 2013 Posted March 1, 2013 Hi! Complementing my sample about printing HTML from Dataset using UniURLFrame. For a basic reporting solution. Now I share a code to send the HTML using Indy, tested with version 10.5.8. My other topic is (Dataset To HTML - Report): http://forums.unigui.com/index.php?/topic/2696-dataset-to-html-report/ The code to send email is threaded and works with Exchange and Google servers. May contain errors. Sorry. Use at your own risk. How to use? 1) Download the pas file attached (the thread); 2) Download the precompiled OpenSSL libraries for your correct windows version 32/64 bits: Author: Arvid Winkelsdorf, digivendo GmbH, www.digivendo.com for The Indy Project, www.indyproject.org I have them here if anyone wants. Save the files libeay32.dll and ssleay32.dll inside the folder of your application. 3) Code like this to send an HTML email: ThdSM := TThdSendMail.Create; ThdSM.EmailData.edSMTPUserName := 'account@domain.com.br'; ThdSM.EmailData.edSMTPPassword := 'myhiddenpassword'; ThdSM.EmailData.edSMTPServer := 'theexchangeserver'; ThdSM.EmailData.edSMTPPort := 587; ThdSM.EmailData.edSSLConnection := true; ThdSM.EmailData.edUseTLS := utUseExplicitTLS; ThdSM.EmailData.edSenderEmail := ThdSM.EmailData.edSMTPUserName; ThdSM.EmailData.edSenderApp := 'Sender Information'; ThdSM.EmailData.edToEmail := 'recipient1,recipient2,recipient3'; ThdSM.EmailData.edSubject := 'subject'; ThdSM.EmailData.edBody.Text := ToHTML.HTML.Text; // THE HTML CONTENT ThdSM.EmailData.edPriority := mpNormal; ThdSM.EmailData.edTimeOut := 15000; // 15 segundos // run thread, send mail ThdSM.Start; // ThdSM.FreeOnTerminate is set true inside create, so we don't need to free here Attention!!!! Inside the ThdSendMail thread the code is currently configured to work with Exchange servers, to use google or other configurations you should change some properties like: SSLHandler.SSLOptions.Method := sslvTLSv1; SSLHandler.SSLOptions.Mode := sslmClient; and maybe port But works with gmail too, tested. I just don't have the correct config now. Bye! Bruno UnitThdSendMail.zip 3 Quote
bruno-pere Posted March 4, 2013 Author Posted March 4, 2013 Hope you enjoy!!! I lost an entire day trying a lot of implementations and combinations before it worked. Bye! Bruno 1 Quote
mhmda Posted April 29, 2013 Posted April 29, 2013 Hi, Could this: send an image inside the html body? Quote
bruno-pere Posted April 30, 2013 Author Posted April 30, 2013 You need to change some code for this. Read here and then try to make the changes. http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23104746.html http://stackoverflow.com/questions/14279211/sending-email-with-indy-9-with-an-embedded-picture Quote
bruno-pere Posted May 7, 2013 Author Posted May 7, 2013 The code is using idSMTP with OpenSSL. Bruno Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.