How to send an Email from ASP .NET



<add key=”ToAddress” value=””>
<add key=”FromAddress” value=””>
<add key=”host” value=”HOST”>

<smtp deliveryMethod=”Network” from=””>
<network host=”localhost” port=”25″ defaultCredentials=”true”/>

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;

/// Summary description for MessageMailSend
public class MessageMailSend
public MessageMailSend()
// TODO: Add constructor logic here
public static bool SendMessage(string to,string from,string subject,string message)
MailMessage msg = new MailMessage();
msg.To = to;
msg.Subject = subject;
msg.From = from;
msg.BodyFormat = MailFormat.Text;
msg.Body = message;
return true;
catch (Exception exp)
return false;


Author: Imran Akram

A .NET/SharePoint Consultant and a political enthusiast who believes in putting the feet of the elected and/or unelected officials to fire in order to get good governance.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s