异步邮件在vs2010 C#中发送,具有传递状态 [英] Asyncronous mail send in vs2010 C# with delivery status

查看:75
本文介绍了异步邮件在vs2010 C#中发送,具有传递状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我使用smtp.sendasync方法发送批量电子邮件。有时它会将邮件状态显示为成功,但不会在目的地收到电子邮件。如何使用异步方法获取未传递邮件的状态。请建议。



我尝试过:



String eid =用户名;

String pass =密码;

System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(eid,pass);

smtpClient.Host =smtp.rediffmailpro.com;

smtpClient.Port = 587;

smtpClient.UseDefaultCredentials = false;

// smtpClient.EnableSsl = true;

smtpClient.Credentials = basicAuthenticationInfo;

try

{

//

smtpClient.SendCompleted + =(s,e)=> smtpClient.Dispose();

smtpClient.SendAsync(message,null);



//smtpClient.Send(message);

返回true;

}

catch(Exception exc)

{

WriteToFile( 电子邮件发送失败:{0}+ exc.Message +。来自电子邮件ID+ msg.Headers.From.Address.ToString());

返回false;

}



I am sending bulk emails using smtp.sendasync method. Some times it shows mail status as success but the emails are not received at destination. how to get status of undelivered mails with asyncronous method. Please suggest.

What I have tried:

String eid = username;
String pass = password;
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(eid, pass);
smtpClient.Host = "smtp.rediffmailpro.com";
smtpClient.Port = 587;
smtpClient.UseDefaultCredentials = false;
// smtpClient.EnableSsl = true;
smtpClient.Credentials = basicAuthenticationInfo;
try
{
//
smtpClient.SendCompleted += (s, e) => smtpClient.Dispose();
smtpClient.SendAsync(message, null);

//smtpClient.Send(message);
return true;
}
catch (Exception exc)
{
WriteToFile("Email Send Failure: {0} " + exc.Message + ". From Email Id " + msg.Headers.From.Address.ToString());
return false;
}

推荐答案

你没有。除非您使用读取收据并且用户实际将其发回,否则您的代码无法确定邮件是否已成功发送。



你最好得到的是你用来发送电子邮件的邮箱中的退回邮件。
You don't. Unless you use a read-receipt and the user actually send it back, there is no way for your code to determine if the mail was successfully sent or not.

The best you're going to get is a bounce message in the mailbox that you're using to send the emails from.


这篇关于异步邮件在vs2010 C#中发送,具有传递状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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