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...

Any ideas why running IDE as administrator on Windows 7 still will not debug?


John

 

From: David O'Brien 
Sent: Thursday, July 14, 2011 7:12 PM
To: NZ Borland Developers Group - Delphi List 
Subject: Re: [DUG] Email/SMTP code

Put the code in another project that doesn’t require admin access?

What server are you pointing at, and are you going through a proxy server?

 

Username & password are both blank in my implementation.

 

Here is a bit more up to date version from another project, this returns any 
error message.

function SendEmail(msgFrom, msgTo, msgCC, msgBCC, msgSubject: String; msgBody: 
TStringList; Attachments: TStringList): String ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  Result := '' ;

  try

    if ASettings.SMTPServer <> '' then

    begin

      SMTP := TidSMTP.Create(nil) ;

      IdMessage := TIdMessage.Create(SMTP);

      try

        MsgTo := Trim(MsgTo) ;

        if Length(MsgTo) > 0 then

          if MsgTo[Length(MsgTo)] = ';' then

            Delete(MsgTo, Length(MsgTo), 1) ;

        MsgCC := Trim(MsgCC) ;

        if Length(MsgCC) > 0 then

          if MsgCC[Length(MsgCC)] = ';' then

            Delete(MsgCC, Length(MsgCC), 1) ;

        MsgBCC := Trim(MsgBCC) ;

        if Length(MsgBCC) > 0 then

          if MsgBCC[Length(MsgBCC)] = ';' then

            Delete(MsgBCC, Length(MsgBCC), 1) ;

        idMessage.Clear ;

        idMessage.From.Address := msgFrom ;

        if MsgTo <> '' then

          idMessage.Recipients.Add.Address := msgTo ;

        if MsgCC <> '' then

          idMessage.CCList.Add.Address := msgCC ;

        if MsgBCC <> '' then

          idMessage.BccList.Add.Address := msgBCC ;

        idMessage.Subject := msgSubject ;

        with TIdText.Create(IdMessage.MessageParts, nil) do

        begin

          Body.Assign(msgBody) ;

          ContentType := 'text/html';

        end;

        if Assigned(Attachments) then

          for i := 0 to pred(Attachments.Count) do

            with TIdAttachmentFile.Create(idMessage.MessageParts, 
Attachments[i]) do

            begin

              ContentID := inttoStr(1000+i) ;

              ContentType := 'image/jpeg' ;

              Filename := ExtractFileName(Attachments[i]) ;

            end;

        t := now ;

        while (SMTP.Connected) and

          (now < t + 10 * (1/86400)) do // 10 Seconds

          sleep(10) ;

        SMTP.Host := ASettings.SMTPServer ;

        SMTP.Port := ASettings.SMTPPort ;

        SMTP.Username := ASettings.Username ;

        SMTP.Password := ASettings.Password ;

        SMTP.Connect ;

        try

          SMTP.Send(idMessage) ;

        finally

          SMTP.Disconnect ;

        end ;

      finally

        SMTP.Free ;

      end;

    end;

  except

    on e: Exception do

    begin

      Result := msgTo+': '+e.Message ;

      EmailFailed := True ;

    end;

  end ;

end ;

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of John Bird
Sent: Thursday, 14 July 2011 6:06 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Email/SMTP code

 

Trying to debug this SMTP program, having tweaked the code a little – I am 
getting “Connection timed out” 

 

However I cannot debug, as on Windows 7 this program requires admin access.

 

I restarted the IDE (BDS.EXE) running as administrator but still get the error 
message

 

“Cannot create process”   (Debug)

 

or

 

“Access denied”  (Run without debugger).

 

Can run the program outside of the IDE by right clicking and selecting “Run as 
administrator” but there is no debugging then!

 

What have I missed?

 

John



--------------------------------------------------------------------------------
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Reply via email to