BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple Ques: Indy POP3 and attachments..

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Joseph
Guest





PostPosted: Mon Sep 22, 2003 9:37 pm    Post subject: Simple Ques: Indy POP3 and attachments.. Reply with quote



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





PostPosted: Mon Sep 22, 2003 11:04 pm    Post subject: Re: Simple Ques: Indy POP3 and attachments.. Reply with quote




"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





PostPosted: Tue Sep 23, 2003 4:33 pm    Post subject: Re: Simple Ques: Indy POP3 and attachments.. Reply with quote



Thanks.. the casting worked!

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.