How to save email attachment using OpenPop

前端 未结 7 933
渐次进展
渐次进展 2020-12-30 09:29

I have created a Web Email Application, How do I view and save attached files?

I am using OpenPop, a third Party d

7条回答
  •  粉色の甜心
    2020-12-30 10:11

     List lstMessages = FetchAllMessages("pop.mail-server.com", 995, true,"Your Email ID", "Your Password");
    

    The above line of code gets the list of all the messages from your email using corresponding pop mail-server.

    For example, to get the attachment of latest (or first) email in the list, you can write following piece of code.

     List lstAttachments = lstMessages[0].FindAllAttachments();  //Gets all the attachments associated with latest (or first) email from the list.
     for (int attachment = 0; attachment < lstAttachments.Count; attachment++)
     {
             FileInfo file = new FileInfo("Some File Name");
             lstAttachments[attachment].Save(file);
     } 
    

提交回复
热议问题