Article View: borland.public.cppbuilder.internet.socket
Article #1144Re: problem using INDY component when sending email
From: Remy Lebeau (TeamB)
Date: Tue, 27 Mar 2007 18:16
Date: Tue, 27 Mar 2007 18:16
66 lines
2787 bytes
2787 bytes
"Van Wouwe Francois" <francois.van.wouwe@skynet.be> wrote in message
news:4608f043$1@newsgroups.borland.com...
> When I use the SMTP component for sending email, the mail is send
> out, but when I close the form I get an access violation at a given
> address, during the read of that address.
That is because you are using it wrong. Why are you calling
Destroying() at all?
Use this code instead:
extern int RecId_club;
extern String WORKDIR, PROGDIR;
void __fastcall TF_Deelnemers::Email1Click(TObject *Sender)
{
char buf[200];
int taal;
String temp, tornooi, tornooinaam;
IdMessage1->Clear();
...
IdMessage1->Sender->Name = buf;
...
IdMessage1->Sender->Address = buf;
IdMessage1->Recipients->EMailAddresses =
DM->Q_CLUBS->FieldByName("email")->AsString;
IdMessage1->From->Assign(IdMessage1->Sender);
IdMessage1->BccList->EMailAddresses =
"francois.van.wouwe@skynet.be";
...
IdMessage1->Subject = "Confirmation of inscription " +
tornooinaam;
IdMessage1->ContentType = "text/plain";
IdMessage1->Body->Add("Club = " +
DM->Q_CLUBS->FieldByName("nr")->AsString + " " +
DM->Q_CLUBS->FieldByName("naam")->AsString);
....
IdMessage1->Body->Add("");
IdMessage1->Body->Add("With sporty greetings");
...
IdMessage1->Body->Add(buf);
GetPrivateProfileString("Email", "SMTPHost", "", buf,
sizeof(buf), tornooi.c_str());
IdSMTP1->Host = buf;
GetPrivateProfileString("Email", "Username", "", buf,
sizeof(buf), tornooi.c_str());
IdSMTP1->Username = buf;
IdSMTP1->Connect(5000);
try {
IdSMTP1->Send(IdMessage1);
}
__finally {
IdSMTP1->Disconnect();
}
ShowMessage("E-mail is verstuurd");
}
Gambit
Technical Details
Message-ID:
<460951d5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4608f043$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,1c868e923aa6cca0 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <4608f043$1@newsgroups.borland.com> Subject: Re: problem using INDY component when sending email Date: Tue, 27 Mar 2007 10:16:29 -0800 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.83.34.171 Message-ID: <460951d5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1175015893 75.83.34.171 (27 Mar 2007 10:18:13 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail