What methods are there for having .NET code run and handle e-mails as they arrive?

后端 未结 4 1465
伪装坚强ぢ
伪装坚强ぢ 2021-01-15 02:03

I\'ve been tasked with creating some sort of service that will take any e-mail sent to an e-mail address and handle the contents of the e-mail (including binary attachments.

4条回答
  •  甜味超标
    2021-01-15 03:06

    Receiving the email is not the hardest part, parsing, extracting attachments is.

    If any one is interested in commercial product take a look at Mail.dll. It supports IDLE command you have mentioned for instant notifications.

    Mail.dll includes POP3, IMAP clients and powerful MIME parser:

    using(Imap imap = new Imap())
    {
        imap.Connect("imap.server.com");
        imap.Login("user", "password");
    
        imap.SelectInbox();
        List uidList = imap.SearchFlag(Flag.Unseen);
        foreach (long uid in uidList)
        {
            IMail mail = new MailBuilder()
                .CreateFromEml(imap.GetMessageByUID(uid));
            Console.WriteLine(mail.Subject);
        }
        imap.Close(true);
    }
    

    Please note that this is commercial product that I've created.

    You can download it at http://www.lesnikowski.com/mail

提交回复
热议问题