I need to Download all attachments in my email to a local folder

May 1 2012 7:23 AM
Can any one help me to do the following,
I wants to download all my attached files in the email (inbox) automatically to my local folder
I tried with the following code to save the attachments to the local folder, but it throws an exception called imap component not licensed, invalid license key. like that


the code i used is

MailMessageCollection msgs = Imap.QuickDownloadMessages("pop.gmail.com", "[email protected]", "sanmugamsiva");
            if (msgs.Count > 0)
            {
                foreach (MailMessage msg in msgs)
                {
                    if (msg.Attachments.Count > 0)
                    {
                        Console.WriteLine("Attachment size list for message " + msg.UidOnServer.ToString());
                        foreach (Attachment attach in msg.Attachments)
                        {
                            Console.WriteLine(attach.Size.ToString());
                        }
                    }
                    else
                    {
                        Console.WriteLine("Message " + msg.UidOnServer.ToString() +" has no attachments");
                    }
                    Console.WriteLine();
                }
            }

Answers (1)