Article View: borland.public.cppbuilder.internet.socket
Article #1966Re: TIdAttachment Problem with MIME Encoding
From: Robert Lieblich
Date: Fri, 22 Sep 2006 10:42
Date: Fri, 22 Sep 2006 10:42
155 lines
5960 bytes
5960 bytes
Hi Remy,
>If you really want to do that,
>then you have to use "application/octet-stream" instead (which is what Indy
>defaults to for uknown types).
>
That's perfect for me!
>> By the way, when you put the text message in a text-attachment like that:
>> ...
>> TIdText *text1 = new TIdText(IdMessage1->MessageParts, NULL);
>> text1->Body->Add("Some text...");
>> text1->ContentType = "text/plain";
>> ...
>> and not in the IdMessage1->Body, it's not possible to use UUEncoding
>
>Yes, it is. Simply set the TIdMessage::Encoding property to meUU, which in
>turn sets the AttachmentEncoding property to "UUE".
>
>> Indy gives an errormessage that only a simple textmessage plus
>> attachment are allowed in UU-mode
>
>Then you are likely using an old version.
>
The one delivered with my BDS2006, the info says: 9.0.50.
I have attached the code here, maybe you want to check
yourself. With my BDS/Indy I get the mentioned exception,
so I succeeded only when the part with text1 is commented.
With IdMessage1->Encoding = meMIME it's working(but text1 ignored).
------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
IdMessage1->Clear();
IdMessage1->Encoding = meUU;
TIdText *text1 = new TIdText(IdMessage1->MessageParts, NULL);
text1->Body->Add("Some text 2. ...");
text1->ContentType = "text/plain";
IdMessage1->Body->Add("Some text...");
IdMessage1->ContentType = "text/plain";
TIdAttachment *attach1 = new TIdAttachment(IdMessage1->MessageParts,
"c:\\attachment.zip");
attach1->ContentType = "application/octet-stream";
TIdAttachment *attach2 = new TIdAttachment(IdMessage1->MessageParts,
"c:\\attachment.txt");
attach2->ContentType = "application/octet-stream";
TIdAttachment *attach3 = new TIdAttachment(IdMessage1->MessageParts,
"c:\\attachment.pdf");
attach3->ContentType = "application/octet-stream";
IdMessage1->From->Name = "SENDERNAME";
IdMessage1->From->Address = "SENDERADDRESS";
IdMessage1->Subject = "Test BDS2006/Indy9.0.50 22.9.06" ;
IdMessage1->Recipients->EMailAddresses = Edit2->Text;
IdMessage1->ContentType = "multipart/mixed";
IdMessage1->SaveToFile("c:\\msg.txt",false) ;
IdSMTP1->Host = Edit7->Text;
if( CheckBox1->Checked )
{
IdSMTP1->Username = Edit4->Text;
IdSMTP1->Password = Edit5->Text;
IdSMTP1->AuthenticationType = atLogin;
}
else
IdSMTP1->AuthenticationType = atNone;
IdSMTP1->Connect(4000);
try
{
IdSMTP1->Send(IdMessage1);
}
__finally {
IdSMTP1->Disconnect();
}
IdMessage1->Clear();
}
---------------------------------------------------------
>> And, in MIME mode, this text is ignored at the receiving mailserver
>> (or the mailclient?)
>
>Only if the message is malformed to begin with, or the receiver is buggy.
>
No, the text is not generated by Indy, take a look at the
output done with IdMessage1->SaveToFile().
There is no reference for: text1->Body->Add("Some
text 2. ..."); in the file.
This output is visible: IdMessage1->Body->Add("Some text...");
-----------------------------------------------------
From: "SENDERNAME" <SENDERADDRESS>
Subject: Test BDS2006/Indy9.0.50 22.9.06
To: lieblich.robert@xxx.xxx
Content-Type: multipart/mixed; boundary="=_MoreStuf_2zzz1234sadvnqw3nerasdf"
MIME-Version: 1.0
Date: Fri, 22 Sep 2006 11:56:57 +0200
This is a multi-part message in MIME format
--=_MoreStuf_2zzz1234sadvnqw3nerasdf
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Some text...
--=_MoreStuf_2zzz1234sadvnqw3nerasdf
Content-Type: application/octet-stream;
name="attachment.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="attachment.zip"
UEsDBBQAAAAIAH1yKi7fikQuOA0AAABEAAATAAAATm90ZWJvb2tzX01pZXRlLnhsc+1cDXBcVRU+
...
AABOb3RlYm9va3NfTWlldGUueGxzUEsFBgAAAAABAAEAQQAAAGkNAAAAAA==
--=_MoreStuf_2zzz1234sadvnqw3nerasdf
Content-Type: application/octet-stream;
name="attachment.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="attachment.txt"
VEVTVE1BSUwNCg0KdGVzdG1haWwgYXR0YWNobWVudA0K5Pb8X19f319fX8TW3A0KPD48Pjw+MTIz
NDU2Nzg5MA0KRW5kZSE=
--=_MoreStuf_2zzz1234sadvnqw3nerasdf
Content-Type: application/octet-stream;
name="attachment.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="attachment.pdf"
JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29k
...)
4EBhlLw08SkooL+/J0f1WEFY4EBhlLw08SldCj4+CnN0YXJ0eHJlZgozMjAxNQolJUVPRgo=
--=_MoreStuf_2zzz1234sadvnqw3nerasdf--
.
Regards Robert
Technical Details
Message-ID:
<4513be2e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!out04a.usenetserver.com!news.usenetserver.com!in01.usenetserver.com!news.usenetserver.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<45112258$1@newsgroups.borland.com> <45117004$1@newsgroups.borland.com> <45118fd7$1@newsgroups.borland.com> <4511bc98$1@newsgroups.borland.com> <4512da05@newsgroups.borland.com> <4512e0ae$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,edd2a3551c00f96a X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Robert Lieblich" <nospam@nospam.com> Sender: "Robert Lieblich" <nospam@nospam.com> Reply-To: "Robert Lieblich" <nospam@nospam.com> Subject: Re: TIdAttachment Problem with MIME Encoding Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 145.253.232.148 X-Forwarded-For: unknown References: <45112258$1@newsgroups.borland.com> <45117004$1@newsgroups.borland.com> <45118fd7$1@newsgroups.borland.com> <4511bc98$1@newsgroups.borland.com> <4512da05@newsgroups.borland.com> <4512e0ae$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <4513be2e$1@newsgroups.borland.com> Date: 22 Sep 2006 03:42:54 -0700 X-Trace: newsgroups.borland.com 1158921774 207.105.83.66 (22 Sep 2006 03:42:54 -0700) Lines: 155 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!out04a.usenetserver.com!news.usenetserver.com!in01.usenetserver.com!news.usenetserver.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail