Tuesday, November 23, 2010

Button that will call Outlook express

Hey all,
      Just few days back I tried to implement the mail transferring with .NET I came across some solutions

1) How to send the mail that will automatically call the outlook express on click button finally ?

Here is the solution


               System.Diagnostics.Process.Start("Outlook");
                ProcessStartInfo startInfo = new ProcessStartInfo("Outlook.exe"); // Open Outlook express
                string admin = "mparamasivan@newtglobal.com";
                startInfo.FileName = "mailto:" + admin + "?subject=Applying for Leave" + "&cc=" + offemail + "&body=" + Reason.Text; //Formated mail
              
                Process.Start(startInfo);


2) Through SMTP configuration via g-mail


System.Net.Mail.MailMessage toSend = new System.Net.Mail.MailMessage("from email ID", "To email ID", "Subject", "messageBody");
        SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
        smtp.EnableSsl = true;
        System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential("some gmail id @gmail.com", "password of it");
        smtp.Credentials = mailAuthentication;
        smtp.Send(toSend);


Hope the information vl save ur time.

Happy Coding ;)

No comments: