<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span><a href="http://delphihaven.wordpress.com/2011/07/20/interesting/">http://delphihaven.wordpress.com/2011/07/20/interesting/</a></span></div><div> </div><div>Regards<br><br>Sandeep<br><a rel="nofollow" target="_blank" href="https://market.android.com/details?id=tenthDoor.android">My Android Apps</a><br></div><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> David O'Brien <Dave@iccs.co.nz><br><b><span style="font-weight: bold;">To:</span></b> NZ Borland Developers Group - Delphi List <delphi@delphi.org.nz><br><b><span style="font-weight: bold;">Sent:</span></b> Sunday, 17 July 2011 4:48
PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [DUG] Email/SMTP code<br></font><br><div id="yiv950416528"><style><!--
#yiv950416528
_filtered #yiv950416528 {font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
_filtered #yiv950416528 {font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
#yiv950416528
#yiv950416528 p.yiv950416528MsoNormal, #yiv950416528 li.yiv950416528MsoNormal, #yiv950416528 div.yiv950416528MsoNormal
        {margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"sans-serif";}
#yiv950416528 a:link, #yiv950416528 span.yiv950416528MsoHyperlink
        {
color:blue;
text-decoration:underline;}
#yiv950416528 a:visited, #yiv950416528 span.yiv950416528MsoHyperlinkFollowed
        {
color:purple;
text-decoration:underline;}
#yiv950416528 p
        {
margin-right:0cm;
margin-left:0cm;
font-size:12.0pt;
font-family:"serif";}
#yiv950416528 p.yiv950416528MsoAcetate, #yiv950416528 li.yiv950416528MsoAcetate, #yiv950416528 div.yiv950416528MsoAcetate
        {
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"sans-serif";}
#yiv950416528 span.yiv950416528EmailStyle17
        {
font-family:"sans-serif";
color:windowtext;}
#yiv950416528 span.yiv950416528EmailStyle18
        {
font-family:"sans-serif";
color:#1F497D;}
#yiv950416528 span.yiv950416528EmailStyle20
        {
font-family:"sans-serif";
color:#1F497D;}
#yiv950416528 span.yiv950416528BalloonTextChar
        {
font-family:"sans-serif";}
#yiv950416528 .yiv950416528MsoChpDefault
        {
font-size:10.0pt;}
_filtered #yiv950416528 {
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
#yiv950416528 div.yiv950416528WordSection1
        {}
--></style><div class="yiv950416528WordSection1"><div class="yiv950416528MsoNormal"><span style="color:#1F497D;">True...</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> </span></div><div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm;"><div class="yiv950416528MsoNormal"><b><span lang="EN-US" style="font-size: 10pt; font-family: sans-serif; ">From:</span></b><span lang="EN-US" style="font-size: 10pt; font-family: sans-serif; "> delphi-bounces@delphi.org.nz [mailto:delphi-bounces@delphi.org.nz] <b>On Behalf Of </b>John Bird<br><b>Sent:</b> Sunday, 17 July 2011 2:48 p.m.<br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Subject:</b> Re: [DUG] Email/SMTP code</span></div></div></div><div class="yiv950416528MsoNormal"> </div><div><div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">FYI Your original version had
a small error in it that you fixed in the later version you posted – at the IdMessage.free line – which I should already been free’d by the previous SMTP.free, ie the IdMessage.free was not needed</span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; "> </span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">John</span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; "> </span></div></div><div><div><div class="yiv950416528MsoNormal"><b><span style="font-size:12.0pt;color:black;">From:</span></b><span style="font-size:12.0pt;color:black;"> <a rel="nofollow" ymailto="mailto:Dave@iccs.co.nz" target="_blank" href="mailto:Dave@iccs.co.nz" title="Dave@iccs.co.nz">David O'Brien</a> </span></div></div><div><div><div><div
class="yiv950416528MsoNormal" style="background:whitesmoke;"><b><span style="font-size: 10pt; color: black; font-family: sans-serif; ">Sent:</span></b><span style="font-size: 10pt; color: black; font-family: sans-serif; "> Tuesday, July 12, 2011 2:01 PM</span></div></div><div><div class="yiv950416528MsoNormal" style="background:whitesmoke;"><b><span style="font-size: 10pt; color: black; font-family: sans-serif; ">To:</span></b><span style="font-size: 10pt; color: black; font-family: sans-serif; "> <a rel="nofollow" ymailto="mailto:delphi@delphi.org.nz" target="_blank" href="mailto:delphi@delphi.org.nz" title="delphi@delphi.org.nz">NZ Borland Developers Group - Delphi List</a> </span></div></div><div><div class="yiv950416528MsoNormal" style="background:whitesmoke;"><b><span style="font-size: 10pt; color: black; font-family: sans-serif; ">Subject:</span></b><span style="font-size: 10pt; color: black; font-family: sans-serif; "> Re: [DUG] Email/SMTP
code</span></div></div></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; "> </span></div></div></div><div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;">Wrote this a while ago, but still works...</span></div><div class="yiv950416528MsoNormal"><span style="color:black;"> </span><span style="color:#1F497D;"></span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;">procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody: TStringList; Attachments: TStringList) ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;">var</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> IdMessage: TIdMessage;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP: TIdSMTP;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> t: TDateTime
;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> i: Integer ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;">begin</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> try</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> if ASettings.SMTPServer <> '' then</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> begin</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP := TidSMTP.Create(nil) ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> IdMessage := TIdMessage.Create(SMTP);</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> try</span></div><div class="yiv950416528MsoNormal"><span
style="color:#1F497D;"> idMessage.Clear ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> idMessage.From.Address := msgFrom ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> idMessage.Recipients.Add.Address := msgTo ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> idMessage.Subject := msgSubject ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> if pos('<html', lowercase(msgBody.Text)) <> 0 then</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> idMessage.ContentType := 'text/html' ;</span></div><div class="yiv950416528MsoNormal"><span
style="color:#1F497D;"> if msgBody <> nil then</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> IdMessage.Body.Assign(msgBody) ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> t := now ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> while (SMTP.Connected) and</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> (now < t + 10 * (1/86400)) do // 10 Seconds</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> sleep(10) ;</span></div><div class="yiv950416528MsoNormal"><span
style="color:#1F497D;"> if Assigned(Attachments) then</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> for i := 0 to pred(Attachments.Count) do</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> TIdAttachmentFile.Create(IdMessage.MessageParts, Attachments[i]) ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Host := ASettings.SMTPServer ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Port := ASettings.SMTPPort ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Username := ASettings.Username ;</span></div><div
class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Password := ASettings.Password ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Connect ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> try</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Send(idMessage) ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> finally</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Disconnect ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> end
;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> finally</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> SMTP.Free ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> IdMessage.Free ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> end;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> end;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> except</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> EmailFailed := True ;</span></div><div class="yiv950416528MsoNormal"><span style="color:#1F497D;"> end ;</span></div><div class="yiv950416528MsoNormal"><span
style="color:#1F497D;">end ;</span></div><div class="yiv950416528MsoNormal"><span style="color:black;"> </span><span style="color:#1F497D;"></span></div><div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm;"><div class="yiv950416528MsoNormal"><b><span lang="EN-US" style="font-size: 10pt; color: black; font-family: sans-serif; ">From:</span></b><span lang="EN-US" style="font-size: 10pt; color: black; font-family: sans-serif; "> <a rel="nofollow" ymailto="mailto:delphi-bounces@delphi.org.nz" target="_blank" href="mailto:delphi-bounces@delphi.org.nz">delphi-bounces@delphi.org.nz</a> <a rel="nofollow" ymailto="mailto:[mailto:delphi-bounces@delphi.org.nz]" target="_blank" href="mailto:[mailto:delphi-bounces@delphi.org.nz]">[mailto:delphi-bounces@delphi.org.nz]</a> <b>On Behalf Of </b>John Bird<br><b>Sent:</b> Tuesday, 12 July 2011 1:47 p.m.<br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Subject:</b> [DUG]
Email/SMTP code</span></div></div></div><div class="yiv950416528MsoNormal"><span style="color:black;"> </span></div><div><div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">Anyone got a recommendation for the best (free) code/samples to drive Indy10 for sending an email with attachment</span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; "> </span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">-Indy10.2.3</span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">-Send attachment</span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">-SMTP server and email addresses will be
known</span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; "> </span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">I have tried a couple (eg AtoZed SendMail example) but it seems to time out connecting to the SMTP </span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; "> </span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; ">John</span></div></div><div><div class="yiv950416528MsoNormal"><span style="font-size: 10pt; color: black; font-family: sans-serif; "> </span></div></div></div></div><div class="yiv950416528MsoNormal" align="center" style="text-align:center;"><span style="font-size:12.0pt;color:black;"><hr size="2" width="100%"
align="center"></span></div><div class="yiv950416528MsoNormal"><span style="font-size:12.0pt;color:black;">_______________________________________________<br>NZ Borland Developers Group - Delphi mailing list<br>Post: <a rel="nofollow" ymailto="mailto:delphi@delphi.org.nz" target="_blank" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>Admin: <a rel="nofollow" target="_blank" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a><br>Unsubscribe: send an email to <a rel="nofollow" ymailto="mailto:delphi-request@delphi.org.nz" target="_blank" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe</span></div></div></div></div></div></div><br>_______________________________________________<br>NZ Borland Developers Group - Delphi mailing list<br>Post: <a ymailto="mailto:delphi@delphi.org.nz"
href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>Unsubscribe: send an email to <a ymailto="mailto:delphi-request@delphi.org.nz" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe<br><br></div></div></div></body></html>