Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static SmtpClient mySmtpClient = new SmtpClient("smtp.gmail.com", 587);
- public static void SendEmail(Email myMail)
- {
- mySmtpClient.EnableSsl = true;
- //mySmtpClient.UseDefaultCredentials = true;
- mySmtpClient.Credentials = new NetworkCredential()
- {
- UserName = "sunaulosamajnepal@gmail.com",
- Password = "2016sunaulonepal",
- };
- //create sender address
- MailAddress to = new MailAddress("sunaulosamajnepal@gmail.com", "Sunaulo Pragatisil Samaj Nepal (Golden progressive Society Nepal");
- //create receiver address
- MailAddress receiver = new MailAddress(myMail.To.Trim(), myMail.Name.Trim());
- // create sender addresss
- MailAddress from = new MailAddress(myMail.From.Trim());
- MailMessage Mymessage = new MailMessage(to, receiver, from);
- Mymessage.Subject = myMail.Subject.Trim();
- Mymessage.Body = myMail.Body.Trim();
- mySmtpClient.Send(Mymessage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement