您的当前位置:首页正文

.net发送邮件实现代码

2024-11-02 来源:个人技术集锦
MailMessage objMail = new MailMessage();
objMail.Subject = "邮件主题";
objMail.Body = "邮件正文";
string mfrom = txtFrom.Value; //从页面读取发送者地址
objMail.From = new MailAddress(mfrom);
string mt = txtTo.Value; //从页面读取接收者地址
MailAddress ma = new MailAddress(mt);
objMail.To.Add(ma);
objMail.IsBodyHtml = true;//指示邮件为html格式的值
objMail.Priority = MailPriority.High;//设置邮件的优先级
objMail.Attachments.Add(new Attachment("F:\\aba.doc"));//添加附件
SmtpClient smtp = new SmtpClient();
smtp.Host = "……"//smtp事务的IP地址,如smtp.cc.com
smtp.Send(objMail);//发送邮件
您可能感兴趣的文章:
Top