Sending emails from gmail server
Some time we need to send mails to others from our application, and fro this we need to use some free email server like GMAIL. here is the code using that we can use the gmail mail server to send the mails. I am simply specifying the gmail SMTP server name and the Port number in the code.. take a look…
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(“test@test.com”);
mailMessage.Subject = “Test”;
mailMessage.Body = “<html><body>This is a test mail</body></html>”;
mailMessage.IsBodyHtml = true;
// Create the credentials to login to the gmail account associated with my custom domain
string sendEmailsFrom = “abc@xyz.com”;
string sendEmailsFromPassword = “password”;
NetworkCredential cred = new NetworkCredential(sendEmailsFrom, sendEmailsFromPassword);
SmtpClient mailClient = new SmtpClient(“smtp.gmail.com”, 587);
mailClient.EnableSsl = true;
mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mailClient.UseDefaultCredentials = false;
mailClient.Timeout = 30000;
mailClient.Credentials = cred;
mailClient.Send(mailMessage);
Thanks
Anil Kumar Pandey
System Architect
Green Point Technology (India) Ltd.
Mumbai, Maharshtra
INDIA
Popularity: 4%
Related posts:
- Sending Mails with attachments using Gmail Tweet This Post...
Related posts brought to you by Yet Another Related Posts Plugin.










Leave your response!
You must be logged in to post a comment.