Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: Email Attachments
| Subject: | Re: Email Attachments |
| Posted by: | "Anthoni Gardner" (nononon..@nononon.com) |
| Date: | Tue, 21 Mar 2006 21:31:56 |
Hi Remy,
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4420621d$1@newsgroups.borland.com...
> If the MessageParts collection has items in it, then you will not be able
to
> get the text from the TIdMessage.Body property, because that is not where
> the text is stored. It will be stored as TIdText instances in the
> MessageParts collection instead. Also, you have to take into account that
> there may be multiple TIdText items if the email contain multiple flavors
of
> the text (plain, html, rtf, etc), so make sure you are paying attention to
> the ContentType of each item, and that you pay attention to the nesting
> levels when "multipart/" items are present.
I found a demo code (called MailClient) and have seen this code fragment
//Code
for intIndex := 0 to Pred(Msg.MessageParts.Count) do
begin
if (Msg.MessageParts.Items[intIndex] is TIdAttachment) then
begin //general attachment
[snipped code but see #Comment]
end
else
begin //body text
if Msg.MessageParts.Items[intIndex] is TIdText then
begin
[Snipped code, mail message is here]
end
end;
end;
//End Code
[#Comment]
What I was thinking here, was I could just delete this entire messge safely
and alert the user that an attachment has been found and the entire message
has been discarded.
In the other section, I just use that to output the actual email content
(hopefully).
Is the right way?
Regards
Anthoni