Configure your email settings in Web.Config with your account details.
<system.net>
<mailSettings>
<smtp>
<network host="smtp.gmail.com" port="25" userName="youremail@gmail.com" password="yourpassword" defaultCredentials="false"/>
</smtp>
</mailSettings>
</system.net>
Send email with above SMTP settings like this
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage("frmid@yourdomain.com", "tomailid@anydomain.com");
SmtpClient mailClient = new SmtpClient();
//Assign your Mail Body text
msg.Body = "test mail body";
//Assign Subject of the e-mail
msg.Subject = "subject";
mailClient.EnableSsl = true;
//if you use yahoo then change mailClient.EnableSsl = false;
//Send mail using Web.config setting
mailClient.Send(msg);
}
No comments:
Post a Comment