In ASP.NET (using C#), it is very easy to send email. You need to include the namespace 'System.Web.Mail'. The rest is as follows-
MailMessage mailMsg = new MailMessage();
mailMsg.To = "ToSomeone@mail.com";
mailMsg.From = "FromSomeone@mail.com";
mailMsg.Subject = "subject of mail";
mailMsg.Body = "body of mail";
SmtpMail.Send(mailMsg);
Attachment:
Sending attachment is also simple.
MailAttachment attachment = new MailAttachment("FilePath");
mailMsg.Attachments.Add(attachment);
Note: The FilePath is the path in Server, not in client. So if you want to send attachment, first save the file in server temporarily, send mail and then delete the temporary file.
1 Comment:
Please see the blog Send Spam-free Email using ASP.NET
Post a Comment