System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.From = "abc@sispark.com.cn";
myMail.To = "abc@sispark.com.cn";
myMail.Subject = "基础知识训练";
myMail.Body = "地址已包含在邮件里~~~";
myMail.BodyFormat = MailFormat.Html; //添加附件,fupload是一个文件选择框
myMail.Attachments.Add(new MailAttachment(this.fupload.PostedFile.FileName));
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "用户名");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "密码");
SmtpMail.SmtpServer = "mail.sispark.com.cn";
try
{
SmtpMail.Send(myMail);
}
catch
{ Response.Write("邮件发送错误!"); }