无法在asp.net C#中发送批量电子邮件 [英] Not able to Send bulk emails in asp.net c#

查看:91
本文介绍了无法在asp.net C#中发送批量电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法一起发送批量电子邮件,但仍然没有使用foreach循环或其他循环.
请建议我是否可以一起发送大量电子邮件,需要使用foreach循环

我只能发送喜欢此...........

I m not able to send bulk emails together,still i am not using foreach loop or other Loop.
Please suggest me is it possible to send bulk emails alltogether or not ,Need to use foreach loop

i am only able to send LIKE THIS...........

MailMessage mailMessage = new MailMessage();
               SmtpClient smtpClient = new SmtpClient();
               foreach (string EmailID in EmailAddress)
               {


                       mailMessage = new MailMessage(FormEmailAddress, EmailID, Subject, MailMessage);

                       smtpClient = new SmtpClient();
                       mailMessage.IsBodyHtml = false;
                       smtpClient.UseDefaultCredentials = true;

                       smtpClient.Credentials = new System.Net.NetworkCredential(FormEmailAddress, Password);

                   try
                   {
                       smtpClient.Send(mailMessage);

                   }
                   catch
                   {

                   }
                   finally
                   {
                       mailMessage = null;
                       smtpClient = null;
                   }
                   }

推荐答案

如果您想使用另一种发送批量电子邮件的方法,请尝试此链接.

manage-bulk-emails-aspnet
Try this link if you want to another approach to send bulk emails.

Automated-Email-Notifications-using-SQL-Server-Job-Schedular

manage-bulk-emails-aspnet


如果内容相同,那么为什么要发送n + 1次?
您只需在for循环中添加To地址即可.
If the content is same then why are you going for sending it n+1 times ?
You could simply add To address from your for loop.
MailMessage mailMessage = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
foreach (string EmailID in EmailAddress)
{
mailMessage.Bcc.Add(EmailID); /// see Bcc here
}
mailMessage.Subject = Subject;
mailMessage.From = new MailAddress(FormEmailAddress);
mailMessage.Body = mailMessage;
smtpClient = new SmtpClient();
mailMessage.IsBodyHtml = false;//upto you
smtpClient.UseDefaultCredentials = true; // required ?????
 
smtpClient.Credentials = new System.Net.NetworkCredential(FormEmailAddress, Password); 

try
{
smtpClient.Send(mailMessage);

}
catch
{

}
finally
{
mailMessage = null;
smtpClient = null;
}


这篇关于无法在asp.net C#中发送批量电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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