当前位置:首页 > ASP.NET实例:在vs2005中发送邮件的方法如下:

ASP.NET实例:在vs2005中发送邮件的方法如下:

点击次数:828  更新日期:2010-12-27
\n

在vs2005中发送邮件的方法如下:


System.Net.Mail.SmtpClient client = new SmtpClient();
client.Host = “smtp.163.com”;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(“你的163用户名”, “*****”);
//星号改成自己邮箱的密码
client.DeliveryMethod = SmtpDeliveryMethod.Network;
\n

System.Net.Mail.MailMessage message = new MailMessage(“你的163邮箱地址”, “收件人邮箱地址”);
message.Subject = “测试”;
message.Body = “用自己写的软件发的邮件!”;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
//添加附件
Attachment data = new Attachment(@”附件地址如:e:\\a.jpg”, System.Net.Mime.MediaTypeNames.Application.Octet);
message.Attachments.Add(data);


\n

try
{
client.Send(message);
MessageBox.Show(“Email successfully send.”);
}
catch (Exception ex)
{
MessageBox.Show(“Send Email Failed.” + ex.ToString());
}


测试一下就知道是否可用了。

C#邮件群发器

用上面介绍的方法实现的邮件群发软件

界面设计:



源码下载: Code 演示版下载:Demo

来源:http://www.cnblogs.com/tuyile006/archive/2007/06/15/784446.html

\n