Board index » cppbuilder » Problem Sending Multipart E-mail Message

Problem Sending Multipart E-mail Message


2005-10-26 12:23:48 PM
cppbuilder57
Hi,
I'm using BCB 6 with Indy 9 and I need help to send e-mails with a
text/plain and text/html parts in the same message.
I'm using this code but it's not working for me:
SMTP->Connect();
TIdMessage *IdMessage1 = new TIdMessage(NULL);
IdMessage1->IsEncoded = true;
IdMessage1->ContentType = "multipart/alternative";
TIdText *aTextPart = new TIdText(IdMessage1->MessageParts,NULL);
aTextPart->ContentType = "text/plain";
aTextPart->ContentTransfer = "quoted-printable";
aTextPart->Body->Add("This the plain text part!");
TIdText *aHtmlPart = new TIdText(IdMessage1->MessageParts,NULL);
aHtmlPart->ContentType = "text/html";
aHtmlPart->ContentTransfer = "quoted-printable";
mStream->Position = 0; // it contains the html code part
aHtmlPart->Body->LoadFromStream(mStream);
... regular stuff already tested for Recipients, Subject, FromName,
ReplyTo....
SMTP->Send(IdMessage1);
SMTP->Disconnect();
What could be wrong? Am I initializing the messageparts in the wrong
way?
Should I be using the IdMessage1->Body in some particular way? (here
I'm not initializing it)
Saulo I. Regis
 
 

Re:Problem Sending Multipart E-mail Message

With the code I presented in the previous message I'm receiving the
following message from my ISP SMTP Server (qmail)
****************************
MessageWall: SMTP/FATAL: Server sent a bare LF; please see
cr.yp.to/docs/smtplf.html
****************************
I changed the code line
aTextPart->Body->Add("This the plain text part!");
to
aTextPart->Body->Text = "This the plain text part!";
and the same fatal error comes from the SMTP Server.
What could be generating this error?
An advice, please...
Saulo I. Regis
 

Re:Problem Sending Multipart E-mail Message

Dear Saulo
I'm not sure if you already found a solution. But you could try thi
one
TIdMessage *lMessage
TIdText *lTextPart
IdSMTP1->AuthenticationType = atNone
IdSMTP1->Host = "mail.yourhost.com"
lMessage = new TIdMessage(this)
lMessage->Encoding = meMIME
lMessage->ContentType = "multipart/related"
lMessage->From->Address = " XXXX@XXXXX.COM "
lMessage->Subject = "Give your subject"
lMessage->Recipients->EMailAddresses
" XXXX@XXXXX.COM "
//lMessage->Priority = mpHigh; //mpHighest
lMessage->Body->Clear()
// Use this part for users who don't use e-mailclients with htm
suppor
lTextPart = new TIdText(lMessage->MessageParts, NULL)
lTextPart->Body->Text = "Your content in plaintext"
lTextPart->ContentType = "text/plain";
// Your message using htm
lTextPart = new TIdText(lMessage->MessageParts, NULL)
lTextPart->Body->Text = "Your content in html"
lTextPart->ContentType = "text/html"
IdSMTP1->Connect()
IdSMTP1->Send(lMessage)
IdSMTP1->Disconnect()
Good luck
PiSymbo
 

{smallsort}