首页 新闻 赞助 找找看

邮箱发送问题

1
悬赏园豆:50 [已解决问题] 解决于 2010-11-22 08:50

 

1 delegate bool sendMsgDelegate(string server, string username, string password, string toaddr, string titel, string body); //申明委托
2   private static object obj = new object();
3 static int count = 0; //计数
4   static int sucessCount = 0; //成功的数量
5 static int total = 0; //
6 private static AutoResetEvent autoEvent = new AutoResetEvent(false);
7
8 public static bool sendMsg(string server, string username, string password, string toaddr, string titel, string body)
9 {
10 return EmailBuild.SendMail(server, username, password, toaddr, titel, body);
11 // return true;
12 }
13
14 public static void SendCallBack(IAsyncResult asynceresult)
15 {
16 sendMsgDelegate ss = (sendMsgDelegate)asynceresult.AsyncState;
17 lock (obj)
18 {
19 count++;
20 bool result = ss.EndInvoke(asynceresult);
21 if (result)
22 {
23 sucessCount++;
24 }
25 if (count == total)
26 {
27 autoEvent.Set();
28 }
29 }
30 }
31 /// <summary>
32 /// 邮件群发
33 /// </summary>
34 /// <param name="title">主题</param>
35 /// <param name="body">内容</param>
36 /// <param name="list">会员集合</param>
37 public static void Send(string title, string body, IList<Patti.Model.CustomersInfo> list)
38 {
39 int n = 0;
40 IList<Patti.Model.MailsettingInfo> EmList = (new Patti.BLL.MailsettingService()).GetListByDataTable("*", "", "MailID", 1, 1, "0", out n);
41 if (EmList.Count <= 0)
42 {
43 Loggor.Log("邮箱发送", "GetCountAndTime", "邮箱参数不对");
44 }
45 string server = EmList[0].MailSmtp;
46 string username = EmList[0].MailName;
47 string password = EmList[0].MailPwd;
48 total = list.Count;
49 DateTime t1 = DateTime.Now;
50 sendMsgDelegate ss = new sendMsgDelegate(sendMsg);
51
52 for (int i = 0; i < list.Count; i++)
53 {
54 if (list[i].CEmail != "")
55 {
56 IAsyncResult asyceresult = ss.BeginInvoke(server, username, password, list[i].CEmail, title, body, SendCallBack, ss);
57 }
58 }
59 autoEvent.WaitOne();
60 DateTime t2 = DateTime.Now;
61 //watch.Stop();
62 Loggor.Log("邮箱发送", "GetCountAndTime", "会员总数为:" + list.Count + ";成功发送" + sucessCount + "个邮箱;总花费的时间为:" + (t2 - t1));
63 }

 

问题补充: 日志记录 会员总数为: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的主页 Fry_CiCi | 初学一级 | 园豆:0
提问于:2010-11-18 12:40
< >
分享
最佳答案
0

首先把发送不成功的错误信息输出来看看到底什么问题。还有你的邮件服务器是否支持所哟说邮件,可能有的邮箱被限制了不能发送

收获园豆:30
茂茂 | 老鸟四级 |园豆:2892 | 2010-11-18 13:37
邮箱用的是企业邮箱 不知道为什么 有部分邮件可以发送有部分不可以发送 知道什么原因吗?? 程序太烂了?
Fry_CiCi | 园豆:0 (初学一级) | 2010-11-18 15:16
其他回答(1)
0

如果全部的QQmail的邮件都发不出去,说明你的代理是有问题的

如果是一部分QQmail发不过去,那可能和他们的邮箱的设置是有关系的

收获园豆:20
Tester Chen | 园豆:1690 (小虾三级) | 2010-11-18 16:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册