 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Joseph Guest
|
Posted: Mon Sep 22, 2003 9:37 pm Post subject: Simple Ques: Indy POP3 and attachments.. |
|
|
I am having trouble with the basics of storing an attachment when
retrieving mail using Indy's POP3 component.
This is what I have... Can anyone point me better? I can't seem to find
a POP3 Indy tutorial anywhere. (I found an SMTP tutorial, but the syntax
to get attachments is different) THANKS!!
Here is a simplied version of what I am doing...
-----------
Msg.Clear; // Msg is a TIdMessage
POP3.Retrieve(i,Msg); // i is set previously
i := Msg.MessageParts.AttachmentCount;
S := Msg.MessageParts.Items[0].StoredPathName;
//?
CheckAttachment := TIDAttachment.Create(Msg.MessageParts,'test1.txt');
CheckAttachment.SaveToFile('test.txt');
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Sep 22, 2003 11:04 pm Post subject: Re: Simple Ques: Indy POP3 and attachments.. |
|
|
"Joseph" <spam (AT) paytotheorder (DOT) com> wrote
| Quote: | S := Msg.MessageParts.Items[0].StoredPathName;
|
StoredPathName is not a member of TIdMessagePart. It is a member of
TIdAttachment. You need to cast the pointer returned by the Items[]
property before you can anything with the attachment. You should be doing
something like this instead:
Msg.Clear;
POP3.Retrieve(i,Msg);
for i := 0 to Msg.MessageParts.Count-1 do
begin
if (Msg.MessageParts.Items[i] is TIdAttachment) then
begin
with (Msg.MessageParts.Items[i] as TIdAttachment) do
begin
SaveToFile(FileName);
end;
end;
end;
| Quote: | CheckAttachment := TIDAttachment.Create(Msg.MessageParts,'test1.txt');
CheckAttachment.SaveToFile('test.txt');
|
You're trying to save a newly created attachment, not an attachment that
already existed in the original message.
Gambit
|
|
| Back to top |
|
 |
Joseph Guest
|
Posted: Tue Sep 23, 2003 4:33 pm Post subject: Re: Simple Ques: Indy POP3 and attachments.. |
|
|
Thanks.. the casting worked!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|