Pop3 to SMTP message custom forwarder in C#

2019-02-07 16:47发布

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 possibly changes the "From" as well. I might need to keep some messages on the server until certain conditions are ready for them to be forwarded.

I found a sample using Chilkat .NET components that might work: http://www.example-code.com/csharp/pop3_forwarder.asp

My question is: Are there any other examples of this in the .NET space using any other components?

Thanks!

3条回答
该账号已被封号
2楼-- · 2019-02-07 17:23

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

查看更多
Explosion°爆炸
3楼-- · 2019-02-07 17:24

The following SO questions/answers might help finding components for the POP3 part of your porject:

And you can use SmtpClient in System.Net.Mail for sending the mails:

查看更多
Ridiculous、
4楼-- · 2019-02-07 17:37

I implemented something very similar using MailBee's IMAP, POP and SMTP .NET components.

They're not free, I'm afraid, but I've found them to be pretty solid, and AfterLogic's support is fast.

There's also the free (including source code) LumiSoft Mail Server, that has POP3 relay support to collect messages from a POP3 server and manage them from there, you could adapt that? (It's written in C#, is nice to work with and upgrades cleanly to VS2008). I've had no problems with that either.

查看更多
登录 后发表回答