Thursday, October 11, 2007

how to send email for local machine on any account


//Create Mail Message Object with content that you want to send with mail.
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
   
mail.From=new MailAddress("mymail@gmail.com");
mail.To.Add(new MailAddress("sendmail@yahoo.com"));//enter company name which send
mail.IsBodyHtml=true;
mail.Subject = "Sending Enquiry";
mail.Body = "Enquiry About Company ";
//Proper Authentication Details need to be passed when sending email from gmail
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential("maymail@gmail.com", "password");

//Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
//For different server like yahoo this details changes and you can
//get it from respective server.
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com",587);

//Enable SSL
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.Send(mail);
Response.Flush();      
Response.Write("message was sent successfully!!!");
AJAX, asp, Asp.net, asp.net and sql server security, Asp.net IntemIndex, C#, Css, DataBinder.Eval, DataKeyNames, Datalist, Datapager, DataSet, DataTable, DropDownList, FindControl, gridview, JavaScript, jquery, Listview, Paging, Regex, RegularExpression, Repeater, Server side validation, Sql Server, timer, timercallback, Validation, XML, xmlnode, XPath