You must Sign In to post a response.
  • Category: ASP.NET

    I wish to download attachment in email based on subject line in c#.net

    Hi
    I wish to download attachment in email based on subject line in c#.net. I have POP details kindly let me know how to do.

    Thanks in advance.
    Vinod
  • #763869
    Try something like below code using pop3 class
    using(Pop3 pop3 = new Pop3())
    {
    pop3.Connect("server");
    pop3.UseBestLogin("user", "password");
    foreach (string uid in pop3.GetAll())
    {
    IMail email = new MailBuilder()
    .CreateFromEml(pop3.GetMessageByUID(uid));
    Console.WriteLine(email.Subject);
    // save all attachments to disk
    email.Attachments.ForEach(mime => mime.Save(mime.SafeFileName));
    }
    pop3.Close();
    }

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


Sign In to post your comments