English 中文(简体)
能否捕捉 SmtpClient 发送的电子邮件邮件的“ 邮件识别码 ”?
原标题:Is it possible to capture the "Message-ID" of an email message sent with SmtpClient?

使用SmtpClient 和 class 在.NET中, < href="https://www.hmailserver.com/" rel="nofolnnoreferr"hMailServer ,我目前找不到办法获得发送信件的头值

< 强/ 强> 背后的想法

我试图从程序上追踪无法执行的信息, 所以我必须找到一个方法, 找出来自拒绝特定信息的目标 SMTP 服务器的回复 。

现在我想到了简单记住 Message-ID SMTP头值, 并分析此ID 的邮件 。

我试图查看"https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.mailmessage.mailsage#System_Net_Mail_MailMessage_headers" rel="无跟踪 noreferr"\code> Headers 收藏 ,但是我没有发现任何 Message-ID

" 强 " 我的问题

能否获取我的 SMTP 服务器在发送 < code> MailMessage 实例时添加的 < code> Message- ID 头值?

<强 > 更新2012-05-27

根据>这个例子 我在发送前成功尝试手工生成一个 Message-ID

到目前为止,我的所有例子都发挥了作用,因此,这似乎解决了我的问题。

最佳回答

解决您问题的标准办法是 VERP。 Read Bernstein s 原始文章要找出为什么 Message-Id et al. 不可靠。 http://cr.yp.to/proto/verp.txt

问题回答

您可以在发送电子邮件前添加您自己的邮件代号 。 我使用下一个代码 :

Guid id = Guid.NewGuid(); //Save the id in your database 
mensajeEmail.Headers.Add("Message-Id", String.Format("<{0}@{1}>",id.ToString(),"mail.example.com"));

注:对于下载信息,我使用 OpenPop.Net ,我检查了 messesage.headers.InReplyTo 属性,还有消息 id 已发送。

为.Net 和 SMTP 客户端使用 MailKit 图书馆。

我尝试了另一个解决方案, 以获取 SMTP 客户端发送的信件的 ID, 以追踪任何回信 。

在发送信件前,在信件信头中添加隐藏的 ID 属性,

"https://i.sstatic.net/HdRPX.png" alt="检查此样本"/ >

Now continue and send your message, Wait about 10 Seconds, Then you will use the IMAP Client to get your Sent folder and for each message in your folder, loop over the message headers and check if anyone of them is ==messageIdentity, now you catch your sent message successfully and get any information about it you wand like ID etc...





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签