如何MAILMESSAGE检查在.NET交付? [英] How to check MailMessage was delivered in .NET?

查看:140
本文介绍了如何MAILMESSAGE检查在.NET交付?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,以检查是否SmtpClient成功发送的电子邮件? SmtpClient.Send()似乎并不返回不是例外的任何其他。因此,如果方法完成它是安全的假设将电子邮件成功发送到相应的邮箱?我的code是如下:

  MAILMESSAGE emailMessage = MAILMESSAGE新();
emailMessage.Subject = SubjectText;
emailMessage.IsBodyHtml = IsBodyHtml;
emailMessage.Body = BODYTEXT;
emailMessage.From =新的MailAddress(Settings.Default.FromEmail,Settings.Default.FromDisplayName);//添加收件人
的foreach(在RecipientAddresses.Split字符串recipientAddress(新的char [{,},StringSplitOptions.RemoveEmptyEntries))emailMessage.To.Add(recipientAddress);使用(SmtpClient smtpClient =新SmtpClient())
{
smtpClient.Send(emailMessage);
}


解决方案

没有,就找出如果消息确实没有提供可靠的方法。

这样做将需要访问结束SMTP服务器为每个你发送电子邮件的人。

如果你没有得到一个异常,你可以假设SMTP服务器尽全力提供的电子邮件。

Is there a way to check if SmtpClient successfully delivered an email? SmtpClient.Send() does not appear to return anything other than an exception. So if the method completes is it safe to assume the email will be successfully sent to the appropriate email box? My code is below:

MailMessage emailMessage = new MailMessage();
emailMessage.Subject = SubjectText;
emailMessage.IsBodyHtml = IsBodyHtml;
emailMessage.Body = BodyText;
emailMessage.From = new MailAddress(Settings.Default.FromEmail,Settings.Default.FromDisplayName);

//add recipients
foreach (string recipientAddress in RecipientAddresses.Split(new char[{','},StringSplitOptions.RemoveEmptyEntries))

emailMessage.To.Add(recipientAddress);

using (SmtpClient smtpClient = new SmtpClient())
{
smtpClient.Send(emailMessage);
}

解决方案

No, there is no reliable way to find out if a message was indeed delivered.

Doing so will require access to the end SMTP server for every person you are emailing.

If you do not get an exception, you can assume that the SMTP server did its best to deliver the email.

这篇关于如何MAILMESSAGE检查在.NET交付?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆