<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        color:black;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle23
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle24
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle25
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-NZ link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Put the code in another project that doesn’t require admin access?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>What server are you pointing at, and are you going through a proxy server?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Username & password are both blank in my implementation.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Here is a bit more up to date version from another project, this returns any error message.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>function SendEmail(msgFrom, msgTo, msgCC, msgBCC, msgSubject: String; msgBody: TStringList; Attachments: TStringList): String ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>var<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> IdMessage: TIdMessage;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP: TIdSMTP;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> t: TDateTime ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> i: Integer ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>begin<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Result := '' ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> try<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if ASettings.SMTPServer <> '' then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> begin<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP := TidSMTP.Create(nil) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> IdMessage := TIdMessage.Create(SMTP);<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> try<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> MsgTo := Trim(MsgTo) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if Length(MsgTo) > 0 then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if MsgTo[Length(MsgTo)] = ';' then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Delete(MsgTo, Length(MsgTo), 1) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> MsgCC := Trim(MsgCC) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if Length(MsgCC) > 0 then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if MsgCC[Length(MsgCC)] = ';' then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Delete(MsgCC, Length(MsgCC), 1) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> MsgBCC := Trim(MsgBCC) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if Length(MsgBCC) > 0 then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if MsgBCC[Length(MsgBCC)] = ';' then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Delete(MsgBCC, Length(MsgBCC), 1) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> idMessage.Clear ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> idMessage.From.Address := msgFrom ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if MsgTo <> '' then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> idMessage.Recipients.Add.Address := msgTo ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if MsgCC <> '' then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> idMessage.CCList.Add.Address := msgCC ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if MsgBCC <> '' then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> idMessage.BccList.Add.Address := msgBCC ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> idMessage.Subject := msgSubject ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> with TIdText.Create(IdMessage.MessageParts, nil) do<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> begin<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Body.Assign(msgBody) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> ContentType := 'text/html';<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> end;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> if Assigned(Attachments) then<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> for i := 0 to pred(Attachments.Count) do<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> with TIdAttachmentFile.Create(idMessage.MessageParts, Attachments[i]) do<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> begin<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> ContentID := inttoStr(1000+i) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> ContentType := 'image/jpeg' ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Filename := ExtractFileName(Attachments[i]) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> end;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> t := now ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> while (SMTP.Connected) and<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> (now < t + 10 * (1/86400)) do // 10 Seconds<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> sleep(10) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Host := ASettings.SMTPServer ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Port := ASettings.SMTPPort ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Username := ASettings.Username ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Password := ASettings.Password ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Connect ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> try<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Send(idMessage) ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> finally<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Disconnect ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> end ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> finally<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> SMTP.Free ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> end;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> end;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> except<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> on e: Exception do<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> begin<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Result := msgTo+': '+e.Message ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> EmailFailed := True ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> end;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> end ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>end ;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> delphi-bounces@delphi.org.nz [mailto:delphi-bounces@delphi.org.nz] <b>On Behalf Of </b>John Bird<br><b>Sent:</b> Thursday, 14 July 2011 6:06 p.m.<br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Subject:</b> Re: [DUG] Email/SMTP code<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Trying to debug this SMTP program, having tweaked the code a little – I am getting “Connection timed out” <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>However I cannot debug, as on Windows 7 this program requires admin access.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>I restarted the IDE (BDS.EXE) running as administrator but still get the error message<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>“Cannot create process” (Debug)<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>or<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>“Access denied” (Run without debugger).<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Can run the program outside of the IDE by right clicking and selecting “Run as administrator” but there is no debugging then!<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>What have I missed?<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>John<o:p></o:p></span></p></div></div></div></div></body></html>