2 using System
.Collections
.Generic
;
5 using PumpkinHouse
.Utils
;
7 using PumpkinHouseDatabase
;
9 using System
.Threading
;
15 private static void PrintHelp()
17 Console
.WriteLine("usage: SendEmail.exe [/reset] [<邮件主题> <模板路径>]");
20 private static void ResetRecords()
22 using (DataUtils utils
= new DataUtils())
24 foreach (var u
in utils
.FindAllUsers().ToList())
32 private static void SendEmail(string subject
, string template
, bool test
)
36 Console
.WriteLine("Test Mode");
38 MailClient
.LoadConfiguration("mail.config");
39 // EmailHelper.SendActivityEmail(subject, "728635054@qq.com", template, new string[] { "测试邮件" });
40 using (DataUtils utils
= new DataUtils())
43 var result
= utils
.FindAllUsers().Where(u
=> u
.Receive_Email
== 1 && u
.Email
!= "" && u
.Email_Verified
!= 2 && u
.Email_Sent
!= 1).ToList();
45 foreach (var r
in result
)
47 //if (r.Email == "iujijvjn@126.com")
51 if (!start
) { Console.WriteLine("\tskip"); continue; }
59 SendEmail(subject
, template
, utils
, r
, test
);
63 Console
.WriteLine(r
.Email
+ "\t" + r
.Nick_Name
+ "\t" + e
.Message
);
64 if (e
.Message
.Equals("Mailbox unavailable. The server response was: Connection frequency limited"))
66 Thread
.Sleep(1000 * 60 * 10); // 停止发送10分钟
67 Console
.WriteLine(r
.Email
+ "\t" + r
.Nick_Name
+ "\tRetrying");
80 private static void SendEmail(string subject
, string template
, DataUtils utils
, DB_User r
, bool test
)
82 if (r
.Email
== "raymanyoung@gmail.com" || !test
)
84 EmailHelper
.SendActivityEmail(subject
, r
.Email
, template
, new string[] { r.Nick_Name }
);
87 Console
.WriteLine(r
.Email
+ "\t" + r
.Nick_Name
+ "\tSuccess");
91 static void Main(string[] args
)
93 if (args
.Length
< 1 || args
.Length
> 3)
99 DataUtils
.ConnectionString
= @"Server=localhost\SQLExpress;Database=MutouheziDatabase;Integrated Security=true"; //305906536
101 if (args
.Length
== 1)
103 if (args
[0].Equals("/reset", StringComparison
.OrdinalIgnoreCase
))
115 if (args
.Length
== 3)
117 if (args
[2].Equals("/prod", StringComparison
.OrdinalIgnoreCase
))
119 SendEmail(args
[0], args
[1], false);
127 if (args
.Length
== 2)
129 SendEmail(args
[0], args
[1], true);