日期:2014-05-18  浏览次数:20411 次

请教用asp.net作一个群发邮件功能
用asp.net开发一个群发邮件的功能,支持附件、抄送、密送功能,请问用什么组件比较稳定且容易使用,asp.net自带的mail组件效果怎么样呀?请指教

------解决方案--------------------
string from = "yen@sohu.com ";
string to = "yen@sohu.com ";
string smtpServer = "smtp.sohu.com ";
string smtpUser = "y ";
string smtpPass = "***** ";


System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.From = from;
myMail.To = to;
myMail.Subject = " 测试邮件主题 ";
myMail.Priority = System.Web.Mail.MailPriority.High; //邮件级别,.High、.Low、.Normal
myMail.BodyFormat = System.Web.Mail.MailFormat.Html; //邮件形式,.Text、.Html
System.Web.Mail.MailAttachment a = new System.Web.Mail.MailAttachment( "c:\\winnt\\Greenstone.bmp ");
myMail.Attachments.Add(a);
myMail.Body = " <font size=7 color=red> 测试邮件内容 </font> <br> <img src= 'cid:Greenstone.bmp '> ";

// set SMTP server name
myMail.Fields[ "http://schemas.microsoft.com/cdo/configuration/smtpserver "] = smtpServer;
// set SMTP server port
myMail.Fields[ "http://schemas.microsoft.com/cdo/configuration/smtpserverport "] = 25;
myMail.Fields[ "http://schemas.microsoft.com/cdo/configuration/sendusing "] = 2;
myMail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ", "1 ");
myMail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername ", smtpUser);
myMail.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ", smtpPass);
System.Web.Mail.SmtpMail.SmtpServer = smtpServer;
try
{
System.Web.Mail.SmtpMail.Send(myMail); //发送邮件
System.Console.WriteLine( "Send success. ");
}
catch (Exception ex)
{
System.Console.WriteLine(ex.InnerException.GetType());
System.Console.WriteLine(ex.StackTrace);
}