发送邮件到多个邮件 [英] Sending mail to more than one mail

查看:133
本文介绍了发送邮件到多个邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个contactUs页面,用户可以在其中输入一些数据,并将该数据发送到许多邮件.
我尝试了多个代码,但是将代码上传到服务器后,该邮件仍未收到任何收信人邮件.

http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx [ ^ ]

http://wiki.asp.net/page.aspx/536/send -asynchronous-mail-using-aspnet/ [

hi all

i have acontactUs page which in it the user will enter some data and that data will be delivered to many mails.
i tried more than one code but after uploading thecode on my server , the mail doesn''t reach any recivers mail.

http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx[^]

http://wiki.asp.net/page.aspx/536/send-asynchronous-mail-using-aspnet/[^]

So, Any Help ,Please???????

Thanks

推荐答案

最可能的原因是您的邮件服务器设置不正确或邮件服务器没有中继电子邮件.尝试使用常规的电子邮件客户端通过邮件服务器发送电子邮件,并查看电子邮件是否已交付.
Most probable cause is that your mail server settings are either not correct or your mail server does not relay email. Try to send an email using a regular email client with your mail server and see if the emails are delivered.


请使用以下代码发送邮件.
在收件人"字段中,您可以指定逗号分隔的电子邮件.

Please use following code to send mail.
In To field you can specify comma seperated email.

sendEmail("Test Subject", "me@mail.com", "user1@mail.com,user2@mail.com,user3@mail.com", "Body of email", "", "",null);
 
public static bool sendEmail(string strSubject, string strFrom, string strTo, string strBody, string strCc, string strBcc,string displayName)
{
System.Net.Mail.SmtpClient Mail = new System.Net.Mail.SmtpClient();
Mail.Host = clsCommon.value("SMTPServer").ToString();
 

string username = null;
string Password = null;

Mail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
username = "MailUserName";
Password = "MailPassword";
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(username, Password);

Mail.UseDefaultCredentials = false;
Mail.Credentials = basicAuthenticationInfo;


 
System.Net.Mail.MailMessage myMail = new System.Net.Mail.MailMessage();
myMail.Subject = strSubject;
 
myMail.From = new System.Net.Mail.MailAddress(strFrom,displayName);
myMail.To.Add(new System.Net.Mail.MailAddress(strTo));
if (!string.IsNullOrEmpty(strCc))
{
myMail.CC.Add(new System.Net.Mail.MailAddress(strCc));
}
if (!string.IsNullOrEmpty(strBcc))
{
myMail.Bcc.Add(new System.Net.Mail.MailAddress(strBcc));
}

myMail.IsBodyHtml = true;
myMail.Body = strBody;
try
{
 
Mail.Send(myMail);
 

return true;
}
catch (Exception ex)
{
ex.Message.ToString();
return false;
}
}


这篇关于发送邮件到多个邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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