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...@delphi.org.nz with Subject:
unsubscribe