【发布时间】:2023-03-07 14:34:01
【问题描述】:
我正在使用 C# 和 .net 进行编码,使用 AWS(亚马逊)SES(简单电子邮件服务)API 一次性发送大约 5000 封邮件,如果发送的邮件数量少于 500,一切正常-600(大约),但如果它更像 5000,它将发送高达 500-600,然后它将停止发送电子邮件。我已经使用datatable来存储数据库中的邮件列表,分配模板正文和主题,然后使用for循环来一一发送电子邮件。我需要知道是编码问题还是 for 循环问题或其他问题?有什么建议对我也有帮助吗?
for (i = 0; i < dtable1.Rows.Count; i++)
{
Object a=dtable1.Rows[i]["student_emailid"];
String TO1=Convert.ToString(a);
TO1 = TO1.Trim();
if (TO1.Equals("")) {
continue;
}
const String FROM = "asit@amcsquare.com"; // Replace with your "From" address. This address must be verified.
String TO = TO1; // Replace with a "To" address. If your account is still in the
// sandbox, this address must be verified.
String SUBJECT = email_subject;
String BODY = templateBody;
// Supply your SMTP credentials below. Note that your SMTP credentials are different from your AWS credentials.
const String SMTP_USERNAME = "XXXXXXXXXXXX"; // Replace with your SMTP username.
const String SMTP_PASSWORD = "XXXXXXXXXXXXXXXXXX"; // Replace with your SMTP password.
// Amazon SES SMTP host name. This example uses the us-west-2 region.
const String HOST = "email-smtp.us-east-1.amazonaws.com";
// Port we will connect to on the Amazon SES SMTP endpoint. We are choosing port 587 because we will use
// STARTTLS to encrypt the connection.
const int PORT = 587;
// Create an SMTP client with the specified host name and port.
using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(HOST, PORT))
{
// Create a network credential with your SMTP user name and password.
client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);
//Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then
//the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL.
client.EnableSsl = true;
System.Net.Mail.MailMessage message1 = new System.Net.Mail.MailMessage(FROM, TO, SUBJECT, BODY);
message1.IsBodyHtml = true;
client.Send(message1);
}
}
【问题讨论】:
-
您是否收到任何错误消息?
-
亚马逊可能正在限制您的电子邮件。 5000 很多,您很可能需要专门用于群发邮件的专用邮件服务器
-
windows服务如何批量处理?
-
我现在已经检查过了。我收到一条错误消息 ----- Uncaught Sys.WebForms.PageRequestManagerTimeoutException: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.
-
您在 SES 上的发送配额是多少?
标签: c# asp.net email amazon-web-services amazon-s3