What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 10082 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Send mail in c# ...
Manna

Send mail in c#

 Code Snippet posted by: Manna | Posted on: 7/30/2012 | Category: C# Codes | Views: 571 | Status: [Member] | Points: 40 | Alert Moderator   


// using this code in send mail button Onclick event


string username = //your name
string answer = null;
string mail = null;


MailMessage msg = new MailMessage();
msg.From = new MailAddress("...."); //from mail id
msg.To.Add(".."); //to mail id
msg.Subject = "sample test";
msg.Body = "UserName:" + username + ";
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.EnableSsl = true;
smtp.Port = 25; // your smtp port number here
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("//user mail id", "//user password");

try
{
smtp.UseDefaultCredentials = false;
smtp.Credentials = SMTPUserInfo;
smtp.Send(msg);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Your Password has been sent to your Email id')", true);
}
catch (Exception exe)
{
Response.Write(exe.Message.ToString());
}

Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 2:49:53 PM