Send mail with attachment in asp.net

//send mail
   MailMessage message = new MailMessage();
   message.To = this.txtEmail.Text.Trim();
   message.From = this.txtMyemail.Text.Trim();
   message.Body = this.txtBody.Text.Trim();
   message.Subject = this.txtTitle.Text.Trim();
   string wsFile = Server.MapPath(Request.ApplicationPath) + "\\Script\\" + site + "_" + strMM + "_WS.txt";
   MailAttachment wsAt = new MailAttachment(wsFile);
   message.Attachments.Add(wsAt);
   string strMailServer = "mail.intel.com";
   SmtpMail.SmtpServer = strMailServer;
   SmtpMail.Send(message);
   Response.Write ("<script language=javascript>alert('Your email was send out successfully.')</script>");

你可能感兴趣的:(Attachment)