View Single Post
Team Leader
28Dec2006,17:13  
pradeep's Avatar
With ASP.Net, it is easy to use the class MailAttachment to send mails with attachments. The following code demonstrates how an attachment can be added to the MailMessage.

Code: ASP.NET
<% @Page Language="C#" %>
 <% @Import Namespace="System.Web.Mail" %>
 <%
 MailMessage msgMail = new MailMessage();
 
 msgMail.To = "postmaster@go4expert.com";
 msgMail.From = "aspMan@go4expert.com";
 msgMail.Subject = "Mail With Attachment";
 
 msgMail.BodyFormat = MailFormat.Text;
 msgMail.Body = "Sent a mail with an attachment!";
 msgMail.Attachments.Add(new MailAttachment("F:\\file\\totalPosts.xls"));
 
 SmtpMail.Send(msgMail);
 
 %>