Pop3 to SMTP message custom forwarder in C#

后端 未结 3 1865
旧时难觅i
旧时难觅i 2021-01-01 06:10

I\'d like to write a service that periodically checks a POP3 account for new messages and based on custom business logic forwards the messages to an appropriate \"To\", and

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 06:10

    Try Mail.dll .NET email component. It has SSL support, POP3 and SMTP clients.

    using(Pop3 pop3 = new Pop3())
    {
        pop3.Connect("mail.host.com");    // Connect to the server 
        pop3.Login("user", "password");
    
        foreach(string uid in pop3.GetAll())
        {
            // Receive mail
            IMail mail = new MailBuilder()
       .CreateFromEml(pop3.GetMessageByUID(uid));
            Console.WriteLine(mail.Subject);
        }
        pop3.Close(true); 
    }
    

    You can download it here

提交回复
热议问题