Download attachment from email

后端 未结 3 1714
无人共我
无人共我 2020-12-10 08:53

How can I browse the email and download all attachments ?

public string Connect_Email ()
{
    string Res = \"\";

    try
    {
        mailclient = new Tcp         


        
3条回答
  •  情歌与酒
    2020-12-10 09:18

    Try something like this

    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();  
     } 
    

    // here is a reference link you can use as well Getting Email Attachments

提交回复
热议问题