Article View: borland.public.cppbuilder.internet.socket
Article #2113Re: How to send an attachment to an e-mail
From: David Ayre
Date: Thu, 17 Aug 2006 17:25
Date: Thu, 17 Aug 2006 17:25
59 lines
2900 bytes
2900 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: > >"David Ayre" <davidcayre@ntlworld.com> wrote in message >news:44e48ddd$1@newsgroups.borland.com... > >> attach->ContentType = "binary"; it works OK > >That is not a proper ContentType value. > >> except that the >> text->Body->Text = acBody; >> doesn't put the body text in. > >Then you did not use it correctly. Please show the actual code you are >using, and the raw data that TIdMessage generates. > >> I have to put it in the IdMessage->Body instead and then it works. > >Do not mix TIdMessage::Body with TIdMessage.MessageParts. Use one or the >other, not both. > > >Gambit > Hi Remy, This is the full code for this section:- //Send Email IdSMTP1->Host = Edit1->Text; IdSMTP1->Port = 25; IdMessage1->From->Address = Edit2->Text; IdMessage1->Recipients->EMailAddresses = Edit3->Text; IdMessage1->Subject = acHeader; //IdMessage1->Body->Text = acBody; IdMessage1->From->Name = Edit4->Text; TIdText *Text = new TIdText(IdMessage1->MessageParts,NULL); Text->ContentType = "text/plain"; Text->Body->Text = acBody; TIdAttachment *Attach = new TIdAttachment(IdMessage1->MessageParts,acAttachment); Attach->ContentType = GetMIMETypeFromFile(Attach->FileName); IdSMTP1->Connect(1000); IdSMTP1->Send(IdMessage1); if(IdSMTP1->Connected())IdSMTP1->Disconnect(); The GetMIMETypeFromFile(Attach->FileName); works now I've got the MIME part in uppercase. If I use the Text->Body->Text = acBody; as above, no body text appears in the body of the e-mail. But if I use the IdMessage1->Body->Text = acBody; it does. acBody, acHeader and acAttachment are char * and contain the correct strings. Cheers, David
Technical Details
Message-ID:
<44e4a6a5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44e2059a$1@newsgroups.borland.com> <44e213f5$1@newsgroups.borland.com> <44e2178f$1@newsgroups.borland.com> <44e2793f$1@newsgroups.borland.com> <44e2da4d$1@newsgroups.borland.com> <44e34fc7@newsgroups.borland.com> <44e48ddd$1@newsgroups.borland.com> <44e49c50$3@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,f90837efd85511de X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "David Ayre" <davidcayre@ntlworld.com> Sender: "David Ayre" <davidcayre@ntlworld.com> Reply-To: "David Ayre" <davidcayre@ntlworld.com> Subject: Re: How to send an attachment to an e-mail Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 62.252.224.18 X-Forwarded-For: 81.96.132.239 References: <44e2059a$1@newsgroups.borland.com> <44e213f5$1@newsgroups.borland.com> <44e2178f$1@newsgroups.borland.com> <44e2793f$1@newsgroups.borland.com> <44e2da4d$1@newsgroups.borland.com> <44e34fc7@newsgroups.borland.com> <44e48ddd$1@newsgroups.borland.com> <44e49c50$3@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <44e4a6a5$1@newsgroups.borland.com> Date: 17 Aug 2006 10:25:57 -0700 X-Trace: newsgroups.borland.com 1155835557 207.105.83.66 (17 Aug 2006 10:25:57 -0700) Lines: 60 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail