Re: [DUG] Email/SMTP code

2011-08-04 Thread David O'Brien
From memory it fails if you try. I think the SMTP component frees them...

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of Ross Levis
Sent: Thursday, 4 August 2011 4:02 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: Re: [DUG] Email/SMTP code

 

I’m basically implementing the code below.  I was wondering why the 
TIdText.Create and TIdAttachmentFile.Create’s don’t need to be freed.  Does 
this occur automatically when the mail is sent?

 

Ross.

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of David O'Brien
Sent: Thursday, 14 July 2011 7:12 p.m.
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

Re: [DUG] Email/SMTP code

2011-08-03 Thread John Bird
Have code working now nicely, email me if anyone wants what I am using.

Is there a way to find the default settings from Outlook or Registry for:

1 - smtp setting
2 - users email address (for the From: address)

At present I have to ask the users for this, should ideally be set from default 
email program settings.

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

Re: [DUG] Email/SMTP code

2011-08-03 Thread Ross Levis
I’m about to implement an option to send an automatic email when a problem 
occurs within the software.  I would be interested in the final code.  Save me 
some trial and error.

 

Cheers,

Ross.

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of John Bird
Sent: Wednesday, 3 August 2011 8:04 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Email/SMTP code

 

Have code working now nicely, email me if anyone wants what I am using.

 

Is there a way to find the default settings from Outlook or Registry for:

 

1 - smtp setting

2 - users email address (for the From: address)

 

At present I have to ask the users for this, should ideally be set from default 
email program settings.

 

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

Re: [DUG] Email/SMTP code

2011-08-03 Thread Ross Levis
I’m basically implementing the code below.  I was wondering why the 
TIdText.Create and TIdAttachmentFile.Create’s don’t need to be freed.  Does 
this occur automatically when the mail is sent?

 

Ross.

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of David O'Brien
Sent: Thursday, 14 July 2011 7:12 p.m.
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

Re: [DUG] Email/SMTP code

2011-07-16 Thread John Bird
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

John

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

Wrote this a while ago, but still works...

 

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody: TStringList; 
Attachments: TStringList) ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts, Attachments[i]) ;

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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

 

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

 

Anyone got a recommendation for the best (free) code/samples to drive Indy10 
for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time out 
connecting to the SMTP 

 

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

Re: [DUG] Email/SMTP code

2011-07-16 Thread David O'Brien
True...

 

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

 

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

 

John

 

From: David O'Brien mailto:d...@iccs.co.nz  

Sent: Tuesday, July 12, 2011 2:01 PM

To: NZ Borland Developers Group - Delphi List mailto:delphi@delphi.org.nz  

Subject: Re: [DUG] Email/SMTP code

 

Wrote this a while ago, but still works...

 

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody: TStringList; 
Attachments: TStringList) ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts, Attachments[i]) ;

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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

 

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

 

Anyone got a recommendation for the best (free) code/samples to drive Indy10 
for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time out 
connecting to the SMTP 

 

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

Re: [DUG] Email/SMTP code

2011-07-14 Thread John Bird
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

Re: [DUG] Email/SMTP code

2011-07-14 Thread David O'Brien
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

Re: [DUG] Email/SMTP code

2011-07-14 Thread John Bird
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

Re: [DUG] Email/SMTP code

2011-07-14 Thread John Bird
Here is details of the “unable to create process” when I try to debug the SMTP 
test program on Windows 7, with the IDE running as administrator

in case anyone has a bright idea whats going on

[20885408]{dbkdebugide100.bpl} Debug.TDebugger.DBKError (Line 11445, 
Debug.pas + 3) + $23
[20852DB1]{dbkdebugide100.bpl} DbkHelper.CheckRetVal (Line 268, DbkHelper.pas 
+ 4) + $8
[20852D31]{dbkdebugide100.bpl} DbkHelper.ErrCode (Line 249, DbkHelper.pas + 
1) + $2
[20877C62]{dbkdebugide100.bpl} Debug.TDebugKernel.CreateProcess (Line 5070, 
Debug.pas + 14) + $2
[20883115]{dbkdebugide100.bpl} Debug.TDebugger.DoCreateProcess (Line 10403, 
Debug.pas + 29) + $36
[20883228]{dbkdebugide100.bpl} Debug.TDebugger.CreateProcess (Line 10429, 
Debug.pas + 6) + $2B
[20883D6D]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 10869, Debug.pas + 
50) + $2D
[208844FA]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 11120, Debug.pas + 
70) + $37
[2087F40A]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 9001, Debug.pas + 0) 
+ $2
[20A469E1]{coreide100.bpl} DebuggerMgr.TDebuggerMgr.Run (Line 1410, 
DebuggerMgr.pas + 4) + $F
[004164FF]{bds.exe } AppMain.TAppBuilder.RunRun (Line 2844, 
ui\AppMain.pas + 0) + $7
[2004018B]{rtl100.bpl  } Classes.TBasicAction.Execute (Line 11081, 
common\Classes.pas + 3) + $7
[20151359]{vcl100.bpl  } ActnList.TContainedAction.Execute (Line 388, 
ActnList.pas + 1) + $2C
[201520BC]{vcl100.bpl  } ActnList.TCustomAction.Execute (Line 1000, 
ActnList.pas + 7) + $8
[20040057]{rtl100.bpl  } Classes.TBasicActionLink.Execute (Line 11010, 
common\Classes.pas + 2) + $7
[2013CA15]{vcl100.bpl  } Controls.TControl.Click (Line 5227, Controls.pas + 
7) + $7
[2019BCF0]{vcl100.bpl  } ComCtrls.TToolButton.Click (Line 17003, ComCtrls.pas 
+ 0) + $0
[2013CEA7]{vcl100.bpl  } Controls.TControl.WMLButtonUp (Line 5365, 
Controls.pas + 6) + $3E
[2013C527]{vcl100.bpl  } Controls.TControl.WndProc (Line 5146, Controls.pas + 
83) + $6
[2013C1B4]{vcl100.bpl  } Controls.TControl.Perform (Line 5021, Controls.pas + 
5) + $C
[2013FEC6]{vcl100.bpl  } Controls.GetControlAtPos (Line 7095, Controls.pas + 
4) + $73
[2013FF8E]{vcl100.bpl  } Controls.TWinControl.ControlAtPos (Line 7118, 
Controls.pas + 13) + $E
[2013C1B4]{vcl100.bpl  } Controls.TControl.Perform (Line 5021, Controls.pas + 
5) + $C
[20140199]{vcl100.bpl  } Controls.TWinControl.IsControlMouseMsg (Line 7182, 
Controls.pas + 15) + $1F
[20140561]{vcl100.bpl  } Controls.TWinControl.WndProc (Line 7269, 
Controls.pas + 76) + $6
[2019DD33]{vcl100.bpl  } ComCtrls.TToolBar.UpdateButtonState (Line 18148, 
ComCtrls.pas + 5) + $1C
[2019DD76]{vcl100.bpl  } ComCtrls.TToolBar.UpdateButtonStates (Line 18158, 
ComCtrls.pas + 3) + $4
[201A06A9]{vcl100.bpl  } ComCtrls.TToolBar.WndProc (Line 19588, ComCtrls.pas 
+ 80) + $6
[2013FDD0]{vcl100.bpl  } Controls.TWinControl.MainWndProc (Line 7073, 
Controls.pas + 3) + $6
[20040E4C]{rtl100.bpl  } Classes.StdWndProc (Line 11583, common\Classes.pas + 
8) + $0
[20163691]{vcl100.bpl  } Forms.TApplication.StopHintTimer (Line 8673, 
Forms.pas + 3) + $6
[201625F0]{vcl100.bpl  } Forms.TApplication.ProcessMessage (Line 8105, 
Forms.pas + 23) + $1
[2016262A]{vcl100.bpl  } Forms.TApplication.HandleMessage (Line 8124, 
Forms.pas + 1) + $4
[2016291F]{vcl100.bpl  } Forms.TApplication.Run (Line 8223, Forms.pas + 20) + 
$3
[0042297A]{bds.exe } bds.bds (Line 195,  + 7) + $7

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

Re: [DUG] Email/SMTP code

2011-07-14 Thread David O'Brien
What version of Delphi? I am running D2009, and can debug without issues on W7 
when running Delphi in admin mode.

Do you have the idSMTP  idMessage components on the form? They are not needed 
for this function.

 

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

 

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 mailto:d...@iccs.co.nz  

Sent: Thursday, July 14, 2011 7:12 PM

To: NZ Borland Developers Group - Delphi List mailto:delphi@delphi.org.nz  

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

Re: [DUG] Email/SMTP code

2011-07-14 Thread Leigh Wanstead
Why not get a Windows XP to debug? Shall not be that hard, right?

2011/7/14 John Bird johnkb...@paradise.net.nz

   Here is details of the “unable to create process” when I try to debug
 the SMTP test program on Windows 7, with the IDE running as administrator

 in case anyone has a bright idea whats going on

 [20885408]{dbkdebugide100.bpl} Debug.TDebugger.DBKError (Line 11445,
 Debug.pas + 3) + $23
 [20852DB1]{dbkdebugide100.bpl} DbkHelper.CheckRetVal (Line 268,
 DbkHelper.pas + 4) + $8
 [20852D31]{dbkdebugide100.bpl} DbkHelper.ErrCode (Line 249, DbkHelper.pas
 + 1) + $2
 [20877C62]{dbkdebugide100.bpl} Debug.TDebugKernel.CreateProcess (Line 5070,
 Debug.pas + 14) + $2
 [20883115]{dbkdebugide100.bpl} Debug.TDebugger.DoCreateProcess (Line 10403,
 Debug.pas + 29) + $36
 [20883228]{dbkdebugide100.bpl} Debug.TDebugger.CreateProcess (Line 10429,
 Debug.pas + 6) + $2B
 [20883D6D]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 10869, Debug.pas
 + 50) + $2D
 [208844FA]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 11120, Debug.pas
 + 70) + $37
 [2087F40A]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 9001, Debug.pas
 + 0) + $2
 [20A469E1]{coreide100.bpl} DebuggerMgr.TDebuggerMgr.Run (Line 1410,
 DebuggerMgr.pas + 4) + $F
 [004164FF]{bds.exe } AppMain.TAppBuilder.RunRun (Line 2844,
 ui\AppMain.pas + 0) + $7
 [2004018B]{rtl100.bpl  } Classes.TBasicAction.Execute (Line 11081,
 common\Classes.pas + 3) + $7
 [20151359]{vcl100.bpl  } ActnList.TContainedAction.Execute (Line 388,
 ActnList.pas + 1) + $2C
 [201520BC]{vcl100.bpl  } ActnList.TCustomAction.Execute (Line 1000,
 ActnList.pas + 7) + $8
 [20040057]{rtl100.bpl  } Classes.TBasicActionLink.Execute (Line 11010,
 common\Classes.pas + 2) + $7
 [2013CA15]{vcl100.bpl  } Controls.TControl.Click (Line 5227, Controls.pas
 + 7) + $7
 [2019BCF0]{vcl100.bpl  } ComCtrls.TToolButton.Click (Line 17003,
 ComCtrls.pas + 0) + $0
 [2013CEA7]{vcl100.bpl  } Controls.TControl.WMLButtonUp (Line 5365,
 Controls.pas + 6) + $3E
 [2013C527]{vcl100.bpl  } Controls.TControl.WndProc (Line 5146,
 Controls.pas + 83) + $6
 [2013C1B4]{vcl100.bpl  } Controls.TControl.Perform (Line 5021,
 Controls.pas + 5) + $C
 [2013FEC6]{vcl100.bpl  } Controls.GetControlAtPos (Line 7095,
 Controls.pas + 4) + $73
 [2013FF8E]{vcl100.bpl  } Controls.TWinControl.ControlAtPos (Line 7118,
 Controls.pas + 13) + $E
 [2013C1B4]{vcl100.bpl  } Controls.TControl.Perform (Line 5021,
 Controls.pas + 5) + $C
 [20140199]{vcl100.bpl  } Controls.TWinControl.IsControlMouseMsg (Line 7182,
 Controls.pas + 15) + $1F
 [20140561]{vcl100.bpl  } Controls.TWinControl.WndProc (Line 7269,
 Controls.pas + 76) + $6
 [2019DD33]{vcl100.bpl  } ComCtrls.TToolBar.UpdateButtonState (Line 18148,
 ComCtrls.pas + 5) + $1C
 [2019DD76]{vcl100.bpl  } ComCtrls.TToolBar.UpdateButtonStates (Line 18158,
 ComCtrls.pas + 3) + $4
 [201A06A9]{vcl100.bpl  } ComCtrls.TToolBar.WndProc (Line 19588,
 ComCtrls.pas + 80) + $6
 [2013FDD0]{vcl100.bpl  } Controls.TWinControl.MainWndProc (Line 7073,
 Controls.pas + 3) + $6
 [20040E4C]{rtl100.bpl  } Classes.StdWndProc (Line 11583,
 common\Classes.pas + 8) + $0
 [20163691]{vcl100.bpl  } Forms.TApplication.StopHintTimer (Line 8673,
 Forms.pas + 3) + $6
 [201625F0]{vcl100.bpl  } Forms.TApplication.ProcessMessage (Line 8105,
 Forms.pas + 23) + $1
 [2016262A]{vcl100.bpl  } Forms.TApplication.HandleMessage (Line 8124,
 Forms.pas + 1) + $4
 [2016291F]{vcl100.bpl  } Forms.TApplication.Run (Line 8223, Forms.pas +
 20) + $3
 [0042297A]{bds.exe } bds.bds (Line 195,  + 7) + $7

 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

Re: [DUG] Email/SMTP code

2011-07-14 Thread John Bird
FYI - Removed a not needed SMTP component from the test project and restarted 
the PC – I think it was the latter, that somehow Windows 7 remembered something 
about the project/exe and still put UAC on it.   Then debugger worked without 
Run as Administrator.

John Bird
JBCL
Contact:
johnkb...@paradise.net.nz
jbc...@xtra.co.nz
027 4844528
http://www.jbcl.co.nz
http://jbclnz.googlepages.com



From: Leigh Wanstead 
Sent: Friday, July 15, 2011 11:37 AM
To: NZ Borland Developers Group - Delphi List 
Subject: Re: [DUG] Email/SMTP code

Why not get a Windows XP to debug? Shall not be that hard, right?


2011/7/14 John Bird johnkb...@paradise.net.nz

  Here is details of the “unable to create process” when I try to debug the 
SMTP test program on Windows 7, with the IDE running as administrator

  in case anyone has a bright idea whats going on

  [20885408]{dbkdebugide100.bpl} Debug.TDebugger.DBKError (Line 11445, 
Debug.pas + 3) + $23
  [20852DB1]{dbkdebugide100.bpl} DbkHelper.CheckRetVal (Line 268, 
DbkHelper.pas + 4) + $8
  [20852D31]{dbkdebugide100.bpl} DbkHelper.ErrCode (Line 249, DbkHelper.pas + 
1) + $2
  [20877C62]{dbkdebugide100.bpl} Debug.TDebugKernel.CreateProcess (Line 5070, 
Debug.pas + 14) + $2
  [20883115]{dbkdebugide100.bpl} Debug.TDebugger.DoCreateProcess (Line 10403, 
Debug.pas + 29) + $36
  [20883228]{dbkdebugide100.bpl} Debug.TDebugger.CreateProcess (Line 10429, 
Debug.pas + 6) + $2B
  [20883D6D]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 10869, Debug.pas + 
50) + $2D
  [208844FA]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 11120, Debug.pas + 
70) + $37
  [2087F40A]{dbkdebugide100.bpl} Debug.TDebugger.Run (Line 9001, Debug.pas + 
0) + $2
  [20A469E1]{coreide100.bpl} DebuggerMgr.TDebuggerMgr.Run (Line 1410, 
DebuggerMgr.pas + 4) + $F
  [004164FF]{bds.exe } AppMain.TAppBuilder.RunRun (Line 2844, 
ui\AppMain.pas + 0) + $7
  [2004018B]{rtl100.bpl  } Classes.TBasicAction.Execute (Line 11081, 
common\Classes.pas + 3) + $7
  [20151359]{vcl100.bpl  } ActnList.TContainedAction.Execute (Line 388, 
ActnList.pas + 1) + $2C
  [201520BC]{vcl100.bpl  } ActnList.TCustomAction.Execute (Line 1000, 
ActnList.pas + 7) + $8
  [20040057]{rtl100.bpl  } Classes.TBasicActionLink.Execute (Line 11010, 
common\Classes.pas + 2) + $7
  [2013CA15]{vcl100.bpl  } Controls.TControl.Click (Line 5227, Controls.pas + 
7) + $7
  [2019BCF0]{vcl100.bpl  } ComCtrls.TToolButton.Click (Line 17003, 
ComCtrls.pas + 0) + $0
  [2013CEA7]{vcl100.bpl  } Controls.TControl.WMLButtonUp (Line 5365, 
Controls.pas + 6) + $3E
  [2013C527]{vcl100.bpl  } Controls.TControl.WndProc (Line 5146, Controls.pas 
+ 83) + $6
  [2013C1B4]{vcl100.bpl  } Controls.TControl.Perform (Line 5021, Controls.pas 
+ 5) + $C
  [2013FEC6]{vcl100.bpl  } Controls.GetControlAtPos (Line 7095, Controls.pas 
+ 4) + $73
  [2013FF8E]{vcl100.bpl  } Controls.TWinControl.ControlAtPos (Line 7118, 
Controls.pas + 13) + $E
  [2013C1B4]{vcl100.bpl  } Controls.TControl.Perform (Line 5021, Controls.pas 
+ 5) + $C
  [20140199]{vcl100.bpl  } Controls.TWinControl.IsControlMouseMsg (Line 7182, 
Controls.pas + 15) + $1F
  [20140561]{vcl100.bpl  } Controls.TWinControl.WndProc (Line 7269, 
Controls.pas + 76) + $6
  [2019DD33]{vcl100.bpl  } ComCtrls.TToolBar.UpdateButtonState (Line 18148, 
ComCtrls.pas + 5) + $1C
  [2019DD76]{vcl100.bpl  } ComCtrls.TToolBar.UpdateButtonStates (Line 18158, 
ComCtrls.pas + 3) + $4
  [201A06A9]{vcl100.bpl  } ComCtrls.TToolBar.WndProc (Line 19588, 
ComCtrls.pas + 80) + $6
  [2013FDD0]{vcl100.bpl  } Controls.TWinControl.MainWndProc (Line 7073, 
Controls.pas + 3) + $6
  [20040E4C]{rtl100.bpl  } Classes.StdWndProc (Line 11583, common\Classes.pas 
+ 8) + $0
  [20163691]{vcl100.bpl  } Forms.TApplication.StopHintTimer (Line 8673, 
Forms.pas + 3) + $6
  [201625F0]{vcl100.bpl  } Forms.TApplication.ProcessMessage (Line 8105, 
Forms.pas + 23) + $1
  [2016262A]{vcl100.bpl  } Forms.TApplication.HandleMessage (Line 8124, 
Forms.pas + 1) + $4
  [2016291F]{vcl100.bpl  } Forms.TApplication.Run (Line 8223, Forms.pas + 20) 
+ $3
  [0042297A]{bds.exe } bds.bds (Line 195,  + 7) + $7

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

Re: [DUG] Email/SMTP code

2011-07-13 Thread David

btw, I was scrolling through the list
did you ever sort out your Indy 10 mailing problem?
(you mentioned it back in March, so here's hoping)
I know how to fix your current Indy version if you are unable/(hitting 
walls) to upgrade it


David


On 13/07/2011 9:42 a.m., David O'Brien wrote:


I think from memory that was to do with the SMTP component being 
already connected to another server. Must have been a good reason at 
the time...


*From:*delphi-boun...@delphi.org.nz 
[mailto:delphi-boun...@delphi.org.nz] *On Behalf Of *David

*Sent:* Tuesday, 12 July 2011 8:26 p.m.
*To:* delphi@delphi.org.nz
*Subject:* Re: [DUG] Email/SMTP code

Erm...
I understand your code works, but you probably want to remove this bit.
The RFC doesn't require a pause

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

Also, to get around the mailservers that block you ( e.g. when they 
don't know you, or think you're a spam bot)

just relay the message through your own ISP
e.g. if you're with orcon, use mail.orcon.net.nz, if you're with ihug, 
use their smtp server...
As long as you have the correct destination email addresses (and 
aren't in fact writing a spam bot), the big mail servers can do the 
work for you


David

On 12/07/2011 2:01 p.m., David O'Brien wrote:

Wrote this a while ago, but still works...

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody: 
TStringList; Attachments: TStringList) ;


var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts, 
Attachments[i]) ;


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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

*From:*delphi-boun...@delphi.org.nz 
mailto:delphi-boun...@delphi.org.nz 
[mailto:delphi-boun...@delphi.org.nz] *On Behalf Of *John Bird

*Sent:* Tuesday, 12 July 2011 1:47 p.m.
*To:* NZ Borland Developers Group - Delphi List
*Subject:* [DUG] Email/SMTP code

Anyone got a recommendation for the best (free) code/samples to drive 
Indy10 for sending an email with attachment


-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

I have tried a couple (eg AtoZed SendMail example) but it seems to 
time out connecting to the SMTP


John



__ Information from ESET Smart Security, version of virus 
signature database 6285 (20110711) __


The message was checked by ESET Smart Security.

http://www.eset.com

  
  
___

NZ Borland Developers Group - Delphi mailing list
Post:delphi@delphi.org.nz  mailto:delphi@delphi.org.nz
Admin:http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email todelphi-requ...@delphi.org.nz  
mailto:delphi-requ...@delphi.org.nz  with Subject: unsubscribe
  
  
__ Information from ESET Smart Security, version of virus signature database 6285 (20110711) __
  
The message was checked by ESET Smart Security.
  
http://www.eset.com
  




__ Information from ESET Smart Security, version of virus 
signature database 6288 (20110712) __


The message was checked by ESET Smart Security.

http://www.eset.com


___
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


__ Information from ESET Smart Security, version of virus signature 
database 6288 (20110712) __

The message was checked by ESET Smart Security.

http://www.eset.com



___
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

Re: [DUG] Email/SMTP code

2011-07-13 Thread David O'Brien
Yes, managed to get 10.2 installed and that sorted the problem.

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
On Behalf Of David
Sent: Wednesday, 13 July 2011 8:00 p.m.
To: delphi@delphi.org.nz
Subject: Re: [DUG] Email/SMTP code

 

btw, I was scrolling through the list
did you ever sort out your Indy 10 mailing problem?
(you mentioned it back in March, so here's hoping)
I know how to fix your current Indy version if you are unable/(hitting
walls) to upgrade it

David


On 13/07/2011 9:42 a.m., David O'Brien wrote: 

I think from memory that was to do with the SMTP component being already
connected to another server. Must have been a good reason at the time...

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
On Behalf Of David
Sent: Tuesday, 12 July 2011 8:26 p.m.
To: delphi@delphi.org.nz
Subject: Re: [DUG] Email/SMTP code

 

Erm...
I understand your code works, but you probably want to remove this bit. 
The RFC doesn't require a pause

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

Also, to get around the mailservers that block you ( e.g. when they
don't know you, or think you're a spam bot)
just relay the message through your own ISP
e.g. if you're with orcon, use mail.orcon.net.nz, if you're with ihug,
use their smtp server...
As long as you have the correct destination email addresses (and aren't
in fact writing a spam bot), the big mail servers can do the work for
you

David

On 12/07/2011 2:01 p.m., David O'Brien wrote: 

Wrote this a while ago, but still works...

 

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody:
TStringList; Attachments: TStringList) ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts,
Attachments[i]) ;

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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

 

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

 

Anyone got a recommendation for the best (free) code/samples to drive
Indy10 for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time
out connecting to the SMTP 

 

John

 



__ Information from ESET Smart Security, version of virus
signature database 6285 (20110711) __

The message was checked by ESET Smart Security.

http://www.eset.com




 
 
___
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
 
 
__ Information from ESET Smart Security, version of virus
signature database 6285 (20110711) __
 
The message was checked by ESET Smart Security.
 
http://www.eset.com
 

 



__ Information from ESET Smart Security, version of virus
signature database 6288 (20110712) __

The message was checked by ESET Smart Security.

http://www.eset.com



 
 
___
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
 
 
__ Information from ESET Smart Security, version of virus
signature database 6288 (20110712) __
 
The message was checked by ESET Smart Security.
 
http://www.eset.com
 

 

___
NZ Borland Developers

Re: [DUG] Email/SMTP code

2011-07-12 Thread David

 Erm...
I understand your code works, but you probably want to remove this bit.
The RFC doesn't require a pause

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

Also, to get around the mailservers that block you ( e.g. when they 
don't know you, or think you're a spam bot)

just relay the message through your own ISP
e.g. if you're with orcon, use mail.orcon.net.nz, if you're with ihug, 
use their smtp server...
As long as you have the correct destination email addresses (and aren't 
in fact writing a spam bot), the big mail servers can do the work for you


David

On 12/07/2011 2:01 p.m., David O'Brien wrote:


Wrote this a while ago, but still works...

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody: 
TStringList; Attachments: TStringList) ;


var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts, 
Attachments[i]) ;


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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

*From:* delphi-boun...@delphi.org.nz 
[mailto:delphi-boun...@delphi.org.nz] *On Behalf Of *John Bird

*Sent:* Tuesday, 12 July 2011 1:47 p.m.
*To:* NZ Borland Developers Group - Delphi List
*Subject:* [DUG] Email/SMTP code

Anyone got a recommendation for the best (free) code/samples to drive 
Indy10 for sending an email with attachment


-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

I have tried a couple (eg AtoZed SendMail example) but it seems to 
time out connecting to the SMTP


John



__ Information from ESET Smart Security, version of virus 
signature database 6285 (20110711) __


The message was checked by ESET Smart Security.

http://www.eset.com


___
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


__ Information from ESET Smart Security, version of virus signature 
database 6285 (20110711) __

The message was checked by ESET Smart Security.

http://www.eset.com



___
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

Re: [DUG] Email/SMTP code

2011-07-12 Thread David O'Brien
I think from memory that was to do with the SMTP component being already
connected to another server. Must have been a good reason at the time...

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
On Behalf Of David
Sent: Tuesday, 12 July 2011 8:26 p.m.
To: delphi@delphi.org.nz
Subject: Re: [DUG] Email/SMTP code

 

Erm...
I understand your code works, but you probably want to remove this bit. 
The RFC doesn't require a pause

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

Also, to get around the mailservers that block you ( e.g. when they
don't know you, or think you're a spam bot)
just relay the message through your own ISP
e.g. if you're with orcon, use mail.orcon.net.nz, if you're with ihug,
use their smtp server...
As long as you have the correct destination email addresses (and aren't
in fact writing a spam bot), the big mail servers can do the work for
you

David

On 12/07/2011 2:01 p.m., David O'Brien wrote: 

Wrote this a while ago, but still works...

 

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody:
TStringList; Attachments: TStringList) ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts,
Attachments[i]) ;

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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

 

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

 

Anyone got a recommendation for the best (free) code/samples to drive
Indy10 for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time
out connecting to the SMTP 

 

John

 



__ Information from ESET Smart Security, version of virus
signature database 6285 (20110711) __

The message was checked by ESET Smart Security.

http://www.eset.com



 
 
___
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
 
 
__ Information from ESET Smart Security, version of virus
signature database 6285 (20110711) __
 
The message was checked by ESET Smart Security.
 
http://www.eset.com
 

 

___
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

Re: [DUG] Email/SMTP code

2011-07-11 Thread David O'Brien
Wrote this a while ago, but still works...

 

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody:
TStringList; Attachments: TStringList) ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts,
Attachments[i]) ;

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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

 

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

 

Anyone got a recommendation for the best (free) code/samples to drive
Indy10 for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time
out connecting to the SMTP 

 

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

Re: [DUG] Email/SMTP code

2011-07-11 Thread Stefan Mueller
Most ISP's nowadays block traffic on port-25 (except to their own mail
servers). 

Helps with infected zombie computers that send out tons of SPAM mails. 

 


Regards,
Stefan

 

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On
Behalf Of John Bird
Sent: Tuesday, July 12, 2011 10:47 AM
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Email/SMTP code

 

Anyone got a recommendation for the best (free) code/samples to drive Indy10
for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time out
connecting to the SMTP 

 

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

Re: [DUG] Email/SMTP code

2011-07-11 Thread Jeremy Coulter
Indy works, but I hate the way it hold up your app. while it sends the
emails !
I dont know what it is, I have asked question, researched, all sorts of
things, but indy sending emails in apps, especially if are trying to do it
as a sperate task to the main running task AND in a thread, it still
appears to lock the app. up until its sent the email or timed out...grrr
I have ditched it now...almost

Jeremy

On Tue, Jul 12, 2011 at 2:05 PM, Stefan Mueller
muell...@orcl-toolbox.comwrote:

 Most ISP’s nowadays block traffic on port-25 (except to their own mail
 servers). 

 Helps with infected zombie computers that send out tons of SPAM mails. ***
 *

 ** **


 Regards,
 Stefan

  

 ** **

 *From:* delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz]
 *On Behalf Of *John Bird
 *Sent:* Tuesday, July 12, 2011 10:47 AM

 *To:* NZ Borland Developers Group - Delphi List
 *Subject:* [DUG] Email/SMTP code

 ** **

 Anyone got a recommendation for the best (free) code/samples to drive
 Indy10 for sending an email with attachment

  

 -Indy10.2.3

 -Send attachment

 -SMTP server and email addresses will be known

  

 I have tried a couple (eg AtoZed SendMail example) but it seems to time out
 connecting to the SMTP 

  

 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

Re: [DUG] Email/SMTP code

2011-07-11 Thread John Bird
Looks good.

Couple of quick questions:

Is this Indy10?   (Indy is notorious for changing properties/names etc between 
versions)

Is Asettings a TidSMTP component?   haven’t figured out yet...

Do you have a copy of the uses clause just in case – I think I have it sorted

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
  IdMessageClient, IdSMTPBase, IdSMTP, IdMessage, IdAttachmentFile;

John

 

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

Wrote this a while ago, but still works...

 

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody: TStringList; 
Attachments: TStringList) ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts, Attachments[i]) ;

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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

 

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

 

Anyone got a recommendation for the best (free) code/samples to drive Indy10 
for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time out 
connecting to the SMTP 

 

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

Re: [DUG] Email/SMTP code

2011-07-11 Thread David O'Brien
v10.2.5

 

ASettings is an object I store all application settings in, the properties in 
this case are strings except SMTPPort (Integer or the like).

 

Don’t know if all these are required, I do a bit of experimentation 
occasionally:

IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, 
IdMessageClient, IdSMTPBase, IdSMTP, IdBaseComponent, IdMessage, 
IdAttachmentFile

 

EmailFailed is not required either (Global Var). I’d probably make this a 
function and return true/false now.

 

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

 

Looks good.

 

Couple of quick questions:

 

Is this Indy10?   (Indy is notorious for changing properties/names etc between 
versions)

 

Is Asettings a TidSMTP component?   haven’t figured out yet...

 

Do you have a copy of the uses clause just in case – I think I have it sorted

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, IdBaseComponent, IdComponent,

  IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,

  IdMessageClient, IdSMTPBase, IdSMTP, IdMessage, IdAttachmentFile;

 

John


 

 

From: David O'Brien mailto:d...@iccs.co.nz  

Sent: Tuesday, July 12, 2011 2:01 PM

To: NZ Borland Developers Group - Delphi List mailto:delphi@delphi.org.nz  

Subject: Re: [DUG] Email/SMTP code

 

Wrote this a while ago, but still works...

 

procedure SendEmail(msgFrom, msgTo, msgSubject: String; msgBody: TStringList; 
Attachments: TStringList) ;

var

  IdMessage: TIdMessage;

  SMTP: TIdSMTP;

  t: TDateTime ;

  i: Integer ;

begin

  try

if ASettings.SMTPServer  '' then

begin

  SMTP := TidSMTP.Create(nil) ;

  IdMessage := TIdMessage.Create(SMTP);

  try

idMessage.Clear ;

idMessage.From.Address := msgFrom ;

idMessage.Recipients.Add.Address := msgTo ;

idMessage.Subject := msgSubject ;

if pos('html', lowercase(msgBody.Text))  0 then

  idMessage.ContentType := 'text/html' ;

if msgBody  nil then

  IdMessage.Body.Assign(msgBody) ;

t := now ;

while (SMTP.Connected) and

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

  sleep(10) ;

if Assigned(Attachments) then

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

TIdAttachmentFile.Create(IdMessage.MessageParts, Attachments[i]) ;

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 ;

IdMessage.Free ;

  end;

end;

  except

EmailFailed := True ;

  end ;

end ;

 

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

 

Anyone got a recommendation for the best (free) code/samples to drive Indy10 
for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time out 
connecting to the SMTP 

 

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

Re: [DUG] Email/SMTP code

2011-07-11 Thread Jolyon Smith
Indy uses blocking sockets - if it didn't, it wouldn't be as easy to work
with.  The down side is that if you call into an Indy client from the main
thread of your app, then that main thread blocks until the Indy call
completes.  In a GUI app that means no message processing and therefore an
apparent freeze.

 

One solution is to make all your Indy calls on a background thread.  But if
putting your Indy calls into a worker thread is too complex/not practical in
your case, then you might have some luck with the AntiFreeze component of
Indy itself:

 

http://www.indyproject.org/docsite/html/frames.html?frmname=topic
http://www.indyproject.org/docsite/html/frames.html?frmname=topicfrmfile=i
ndex.html frmfile=index.html

 

NOTE: I do all my Indy work in threads so have no direct experience of using
AntiFreeze, I just knew it existed.

 

I hope it helps. 

 

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On
Behalf Of Jeremy Coulter
Sent: Tuesday, 12 July 2011 14:36
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Email/SMTP code

 

Indy works, but I hate the way it hold up your app. while it sends the
emails !
I dont know what it is, I have asked question, researched, all sorts of
things, but indy sending emails in apps, especially if are trying to do it
as a sperate task to the main running task AND in a thread, it still
appears to lock the app. up until its sent the email or timed out...grrr
I have ditched it now...almost

Jeremy

On Tue, Jul 12, 2011 at 2:05 PM, Stefan Mueller muell...@orcl-toolbox.com
wrote:

Most ISP's nowadays block traffic on port-25 (except to their own mail
servers). 

Helps with infected zombie computers that send out tons of SPAM mails. 

 


Regards,
Stefan

 

 

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On
Behalf Of John Bird
Sent: Tuesday, July 12, 2011 10:47 AM


To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Email/SMTP code

 

Anyone got a recommendation for the best (free) code/samples to drive Indy10
for sending an email with attachment

 

-Indy10.2.3

-Send attachment

-SMTP server and email addresses will be known

 

I have tried a couple (eg AtoZed SendMail example) but it seems to time out
connecting to the SMTP 

 

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