Archived Forum Post

Index of archived forum posts

Question:

Download attachments in using POP3?

Jan 12 '15 at 20:14

Is it possible to download attachments using POP3 or do I have to use IMAP?

It seems like there are POP3 examples, but when I try to run them, it always tells me that I have zero attachments and/or will not display the attachment even though I know there are several.

Some sample C# code:

            int i;
            Chilkat.Email email = null;
            for (i = 0; i <= bundle.MessageCount - 1; i++)
            {
                email = bundle.GetEmail(i);

                Console.WriteLine("From: " + email.From);
                Console.WriteLine("Subject: " + email.Subject);
                Console.WriteLine("Attachments: " + email.GetAttachmentFilename(i));
                Console.WriteLine("NumAttachments: " + email.NumAttachments.ToString());
                Console.WriteLine(" ------- ");

                if (email.Subject == "test subject") )
                {
                    int numAtt = email.NumAttachments;
                    success = email.SaveAllAttachments("BillingAttachments");

                    if (success != true)
                    {
                        Console.WriteLine(email.LastErrorText);
                        return;
                    }
                }
            }

Answer

Maybe you are downloading headers-only? With POP3, if you are downloading the full email, you'll get all the attachments as well..