C# 如何检测回执的电子邮件是否被退回

C# 如何检测回执的电子邮件是否被退回,c#,imap,pop3,C#,Imap,Pop3,我使用IMAP或POP3从服务器获取电子邮件,并将获取的电子邮件输入数据库,但我注意到有很多被退回的电子邮件输入到系统中,所以我在谷歌上搜索了很多来检查获取的电子邮件,如果是被退回的电子邮件,我将不会将其输入到系统中,我找到library BouncedDetectResult来检测电子邮件是否被退回或者不是,但是这个库只与消息类型MimeMessage一起工作,所以当我使用IMAP时它很有用,但是它与消息类型OpenPop.Mime.message不一起工作,所以当我使用POP3时它不能使用

我使用IMAP或POP3从服务器获取电子邮件,并将获取的电子邮件输入数据库,但我注意到有很多被退回的电子邮件输入到系统中,所以我在谷歌上搜索了很多来检查获取的电子邮件,如果是被退回的电子邮件,我将不会将其输入到系统中,我找到library BouncedDetectResult来检测电子邮件是否被退回或者不是,但是这个库只与消息类型MimeMessage一起工作,所以当我使用IMAP时它很有用,但是它与消息类型OpenPop.Mime.message不一起工作,所以当我使用POP3时它不能使用

 var result= BounceDetectorMail.Detect(message);//message type MimeMessage
        if (result.IsBounce) 
        {
            em.DelivaryFailure = true;
        }

因此,我的问题是,当我使用pop3检索时,我没有找到检测检索到的邮件是否被退回的方法,因为任何人可能需要,从,同时支持pop3和IMAP:

// POP3 server information.
const string serverName = "myserver";
const string user = "name@domain.com";
const string password = "mytestpassword";
const int port = 995;
const SecurityMode securityMode = SecurityMode.Implicit;
// Create a new instance of the Pop3Client class.
Pop3Client client = new Pop3Client();
Console.WriteLine("Connecting Pop3 server: {0}:{1}...", serverName, port);
// Connect to the server.
client.Connect(serverName, port, securityMode);
// Login to the server.
Console.WriteLine("Logging in as {0}...", user);
client.Authenticate(user, password);
// Initialize BounceInspector.
BounceInspector inspector = new BounceInspector();
inspector.AllowInboxDelete = false; // true if you want BounceInspector automatically delete all hard bounces.
// Register processed event handler.
inspector.Processed += inspector_Processed;
// Download messages from Pop3 Inbox to 'c:\test' and process them.
BounceResultCollection result = inspector.ProcessMessages(client, "c:\\test");
// Display processed emails.
foreach (BounceResult r in result)
{
   // If this message was identified as a bounced email message.
   if (r.Identified)
   {
       // Print out the result
       Console.Write("FileName: {0}\nSubject: {1}\nAddress: {2}\nBounce Category: {3}\nBounce Type: {4}\nDeleted: {5}\nDSN Action: {6}\nDSN Diagnostic Code: {7}\n\n",
                       System.IO.Path.GetFileName(r.FilePath),
                       r.MailMessage.Subject,
                       r.Addresses[0],
                       r.BounceCategory.Name,
                       r.BounceType.Name,
                       r.FileDeleted,
                       r.Dsn.Action,
                       r.Dsn.DiagnosticCode);
   }
}
Console.WriteLine("{0} bounced message found", result.BounceCount);
// Disconnect.
Console.WriteLine("Disconnecting...");
client.Disconnect();
看起来您提到的库使用my library来检测消息是否为已跳转消息


好消息是,您可以使用该库,因为我还有一个名为POP3的库,因此您可以使用该库而不是OpenPOP.NET。

谢谢您的回复,但该库不是免费的。您可以使用免费试用版,看看它是否适合您,如果你真的想的话,可以搜索类似的替代品:)是的,我看到这个库可以满足我的要求,但我已经搜索了其他免费库,但我没有找到任何东西