1. Add the following text in the Web.config file for the your application.
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="sendmail@gmail. com">
<network host="smtp.gmail.com" password="password12"
userName="sendmail" defaultCredentials="false" port="587" />
</smtp>
</mailSettings>
</system.net>
i . sendmail@gmail.
ii . sendmail In this place enter your gmailid
iii. password12 In this place enter your gmailpassword
2. Create this form.
2. Add this method to send your mail & call where ever its required.
public void SendMail(string FromEmail, string ToEmail, string CC, string subject, string body)
{
System.Web.Mail.MailMessage Message = new System.Web.Mail.MailMessage();
Message.From = FromEmail;
Message.To = ToEmail;
Message.Cc = CC;
Message.Subject = subject;
Message.Body = body;
Message.BodyFormat = MailFormat.Html;
SmtpMail client = new SmtpMail ();
client.Send (Message);
}
3. On Send Button Event Write this Code
protected void btnSendEmail_Click(object sender, EventArgs e)
{
try
{
SendMail(txtFromID.Text.Trim(), txtToEmailID.Text.Trim(), txtCcEmailID.Text.Trim(),
txtSubject.Text.Trim(), txtBody.Text.Trim());
}
catch (Exception)
{
}
}
4. If you have any other Other Solution please send me.
5. If any issue please comment.
6. Thanks for Reading this Blog.
our new blog site : http://blog.hintechnology.com
No comments:
Post a Comment