Article View: borland.public.cppbuilder.internet.socket
Article #1961Re: TIdAttachment Problem with MIME Encoding
From: Remy Lebeau (TeamB)
Date: Wed, 20 Sep 2006 22:09
Date: Wed, 20 Sep 2006 22:09
62 lines
3516 bytes
3516 bytes
"Robert Lieblich" <nospam@nospam.com> wrote in message
news:45118fd7$1@newsgroups.borland.com...
> this is the (faulty) test-attachment (the correct end would be: ..Ende!):
That is not what I wanted to see. Please show the COMPLETE message data,
including all headers.
> I Your example works, because you use:
> attach1->ContentType = "text/plain";
That is what is supposed to be used, because you are attaching a text file.
The ContentType for a particular message part has to match the actual data
inside that part.
> With attach1->ContentType = "multipart/application";
That is not a valid ContentType value. There is no "application" subtype
defined for the "multipart" media type.
> or "multipart/mixed"
"multipart/mixed" is NOT the correct ContentType to use for your
attachment - unless the attachment contains pre-formatted "multipart" data
to begin with, which is likely not what you are actually doing.
> you get the "additional bytes problem" with the .txt-file and
> with other, e.g. .pdf-files.
The ContentType alone has no effect whatsoever on Indy's encoders. They
don't care about the ContentType at all. The value is written to the header
inside the message data and then ignored for everything else.
> It looks as the problem is caused by the "multipart" phrase.
> Even when you use "mime/image" or "mim/image" or just "image" it'ok...
Those are not valid ContentType values, either.
> I have not tried "attach1->ContentType = "text/plain"; " before
You should have been using that all along. The fact that you don't know how
to use ContentType values properly indicates that you do not understand how
emails actually work in general.
> because i wanted to attach also binary files (attachment.txt was just
> one example), but surprisingly these work also with "text/plain" .
For any file, binary or text, you have to use the proper ContentType. For
example, .txt files must use "text/plain", .htm files must use "text/html",
.pdf must use "application/pdf", .zip files must use
"application/x-zip-compressed", etc. So unless you know for sure off the
top of your head what a given file should use, then you should always use
Indy's GetMIMETypeFromFile() function instead, ie:
attach1->ContentType = GetMIMETypeFromFile(attach1->FileName);
GetMIMETypeFromFile() knows the registered types for a whole bunch of known
file extensions, as well as queries the OS for known types as well.
Gambit
Technical Details
Message-ID:
<4511bc98$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.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:
<45112258$1@newsgroups.borland.com> <45117004$1@newsgroups.borland.com> <45118fd7$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: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <45112258$1@newsgroups.borland.com> <45117004$1@newsgroups.borland.com> <45118fd7$1@newsgroups.borland.com> Subject: Re: TIdAttachment Problem with MIME Encoding Date: Wed, 20 Sep 2006 15:09:17 -0700 Lines: 64 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: 69.169.4.232 Message-ID: <4511bc98$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1158790296 69.169.4.232 (20 Sep 2006 15:11:36 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.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