新微赢技术网
标题:
asp.net发送邮件
[打印本页]
作者:
Nick
时间:
2009-11-30 01:33
标题:
asp.net发送邮件
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
client.Host
= "smtp.163.com";
client.UseDefaultCredentials
= false;
client.Credentials
= new System.Net.NetworkCredential("自已的163邮件地址", "密码");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message
= new System.Net.Mail.MailMessage("自已的163邮件地址", "收件人地址");
message.Subject
= "主题测试";
message.Body
= "asp.net发送邮件";
message.BodyEncoding
= System.Text.Encoding.UTF8;
message.IsBodyHtml
= true;
//添加附件需将(附件先上传到服务器)
System.Net.Mail.Attachment data = new System.Net.Mail.Attachment(@"UpFile\fj.rar",
System.Net.Mime.MediaTypeNames.Application.Octet);
message.Attachments.Add(data);
try
{
client.Send(message);
Response.Write(
"Email successfully send.");
}
catch (Exception ex)
{
Response.Write(
"Send Email Failed." + ex.ToString());
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2