<HTML xmlns="http://www.w3.org/TR/REC-html40" 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"><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<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>
</HEAD>
<BODY dir=ltr lang=EN-NZ bgColor=white vLink=purple link=blue>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Arial'; COLOR: #000000; FONT-SIZE: 10pt">
<DIV>It looks like its the presence of the SMTP and IdMessage components that
cause the UAC (Admin access)....there is only this unit and a test unit to drive
it...</DIV>
<DIV> </DIV>
<DIV>Any ideas why running IDE as administrator on Windows 7 still will not
debug?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV style="FONT-FAMILY: 'Arial'; COLOR: #000000; FONT-SIZE: 10pt">John</DIV>
<DIV
style="FONT-FAMILY: 'Arial'; COLOR: #000000; FONT-SIZE: 10pt"><BR> </DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=Dave@iccs.co.nz
href="mailto:Dave@iccs.co.nz">David O'Brien</A> </DIV>
<DIV><B>Sent:</B> Thursday, July 14, 2011 7:12 PM</DIV>
<DIV><B>To:</B> <A title=delphi@delphi.org.nz
href="mailto:delphi@delphi.org.nz">NZ Borland Developers Group - Delphi List</A>
</DIV>
<DIV><B>Subject:</B> Re: [DUG] Email/SMTP code</DIV></DIV></DIV>
<DIV> </DIV></DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<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-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 0cm; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<P class=MsoNormal><B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: windowtext; FONT-SIZE: 10pt"
lang=EN-US>From:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; COLOR: windowtext; FONT-SIZE: 10pt"
lang=EN-US> 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-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">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-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">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-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">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-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">“Cannot create
process” (Debug)<o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">or<o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">“Access denied”
(Run without debugger).<o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">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-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">What have I
missed?<o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"> <o:p></o:p></SPAN></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt">John<o:p></o:p></SPAN></P></DIV></DIV></DIV></DIV>
<P>
<HR>
_______________________________________________<BR>NZ Borland Developers Group -
Delphi mailing list<BR>Post: delphi@delphi.org.nz<BR>Admin:
http://delphi.org.nz/mailman/listinfo/delphi<BR>Unsubscribe: send an email to
delphi-request@delphi.org.nz with Subject:
unsubscribe</DIV></DIV></DIV></BODY></HTML>