邮箱发送问题

Fry_cici 2010-11-18 12:47:12
      delegate bool sendMsgDelegate(string server, string username, string password, string toaddr, string titel, string body);   //申明委托
private static object obj = new object();
static int count = 0; //计数
static int sucessCount = 0; //成功的数量
static int total = 0; //
private static AutoResetEvent autoEvent = new AutoResetEvent(false);

public static bool sendMsg(string server, string username, string password, string toaddr, string titel, string body)
{
return EmailBuild.SendMail(server, username, password, toaddr, titel, body);
// return true;
}

public static void SendCallBack(IAsyncResult asynceresult)
{
sendMsgDelegate ss = (sendMsgDelegate)asynceresult.AsyncState;
lock (obj)
{
count++;
bool result = ss.EndInvoke(asynceresult);
if (result)
{
sucessCount++;
}
if (count == total)
{
autoEvent.Set();
}
}
}
/// <summary>
/// 邮件群发
/// </summary>
/// <param name="title">主题</param>
/// <param name="body">内容</param>
/// <param name="list">会员集合</param>
public static void Send(string title, string body, IList<Patti.Model.CustomersInfo> list)
{
int n = 0;
IList<Patti.Model.MailsettingInfo> EmList = (new Patti.BLL.MailsettingService()).GetListByDataTable("*", "", "MailID", 1, 1, "0", out n);
if (EmList.Count <= 0)
{
Loggor.Log("邮箱发送", "GetCountAndTime", "邮箱参数不对");
}
string server = EmList[0].MailSmtp;
string username = EmList[0].MailName;
string password = EmList[0].MailPwd;
total = list.Count;
DateTime t1 = DateTime.Now;
sendMsgDelegate ss = new sendMsgDelegate(sendMsg);

for (int i = 0; i < list.Count; i++)
{
if (list[i].CEmail != "")
{
IAsyncResult asyceresult = ss.BeginInvoke(server, username, password, list[i].CEmail, title, body, SendCallBack, ss);
}
}
autoEvent.WaitOne();
DateTime t2 = DateTime.Now;
//watch.Stop();
Loggor.Log("邮箱发送", "GetCountAndTime", "会员总数为:" + list.Count + ";成功发送" + sucessCount + "个邮箱;总花费的时间为:" + (t2 - t1));
}
...全文
153 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ryan20082009 2010-11-19
  • 打赏
  • 举报
回复
http://download.csdn.net/source/2756013 这里有
Fry_cici 2010-11-19
  • 打赏
  • 举报
回复
在顶得肺出血了 ·
Fry_cici 2010-11-19
  • 打赏
  • 举报
回复
应该说来 不管对方的邮箱是否正确 都应该可以发送把
Fry_cici 2010-11-19
  • 打赏
  • 举报
回复
按道理应该可以发送出去很多 不过有很多发送不出去呢??
Fry_cici 2010-11-19
  • 打赏
  • 举报
回复
我不要邮件发送啊
taolinsen 2010-11-19
  • 打赏
  • 举报
回复
是不是肯定是程序的原因?
我做过邮件服务器,可能是DNS解析不够好,也有可能别的邮箱把邮件当作垃圾邮件处理了
Fry_cici 2010-11-18
  • 打赏
  • 举报
回复
信箱对的也这样
by_封爱 版主 2010-11-18
  • 打赏
  • 举报
回复
信箱不对?
Fry_cici 2010-11-18
  • 打赏
  • 举报
回复
日志记录
会员总数为:1068;成功发送288个邮箱;总花费的时间为:00:13:46.1718750

未发送出去的邮箱:123456@qq.com;
异常信息:
在 System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
在 System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
在 System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
在 System.Net.Mail.SmtpClient.Send(MailMessage message)
在 ConsoleApplication1.EmailSend.SendEmail(String sendMan,
String pop3pwd, String reveiceMan, String subject, String body, String smtpServer)
位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\WebSite4\ConsoleApplication1\EmailSen
d.cs:行号 42
没有成功的我都记录下来了 为什么会有这么多邮件发送不出去?? 有那位能说下吗?

Fry_cici 2010-11-18
  • 打赏
  • 举报
回复
Fry_cici 2010-11-18
  • 打赏
  • 举报
回复
那该怎么做啊??
louti 2010-11-18
  • 打赏
  • 举报
回复
是否间隔时间太短的缘故
Fry_cici 2010-11-18
  • 打赏
  • 举报
回复

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧