views:

349

answers:

2

Hi,

I am building an email receiving website. I can read the email with the help of code used in Code Project, but I can't download email attachments.

Can anyone tell me how to download email attachments using POP3?

Thank you!

A: 

When you send an email with an attachment, that file is encoded as base64 and included into your message. So, if you already get your email message, you already got your attachment. Now it's just to decode it.

If you can provide more details on how far did you get, we'll can provide more information to help you to solve this issue.

Rubens Farias
+1  A: 

In one of my projects I used a commercial server component: aspNetPOP3. It does of the "difficult" things (MIME stuff). Works very well for me. Saving an attachment is very easy using that library, for example:

POP3 pop = new POP3("127.0.0.1","[email protected]", "mypassword" );

pop.Connect();
MimeMessage msg = pop.GetMessage(1);

//save attachments to a directory
msg.SaveAttachments( "c:\\temp\\mydirectory\\", true );

pop.Disconnect();
splattne