Click here to Skip to main content
11,706,455 members (37,607 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# MVC3
Hi
I need detailed code for how to send an smtp mail with password encryption.
Posted 4-Dec-12 20:14pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hi dear,

Check this solution.

private void MailSend()
       {
           try
           {
               MailMessage mail = new MailMessage();
               SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
               SmtpServer.Host = "smtp.gmail.com";
 
               mail.From = new MailAddress("FromMailName@gamil.com");
               mail.To.Add("ToMailName@gmail.com");
               mail.Subject = "Test Mail";
               mail.Body = "This is for testing SMTP mail from GMAIL";
 
               SmtpServer.Port = 587;
 
               SmtpServer.Credentials = new System.Net.NetworkCredential("ToMailName@gmail.com", "123456"); // User Mail Name And Mail Password
               SmtpServer.EnableSsl = true;
 
               SmtpServer.Send(mail);
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.ToString());
           }
       }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

try {
WebMail.SmtpServer = "smtp.example.com";
WebMail.SmtpPort = 587;
WebMail.EnableSsl = true;
WebMail.UserName = "mySmtpUsername";
WebMail.Password = "mySmtpPassword";
WebMail.From = "rsvps@example.com";
WebMail.Send("party-host@example.com", "RSVP Notification",
Model.Name + " is " + ((Model.WillAttend ?? false) ? "" : "not")
+ "attending");
} catch (Exception) {
@:<b>Sorry - we couldn't send the email to confirm your RSVP.</b>
}
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

var smtp = new System.Net.Mail.SmtpClient();
   {
       smtp.Host = "smtp.gmail.com";
       smtp.Port = 587;
       smtp.EnableSsl = true;
       smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
       smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
       smtp.Timeout = 20000;
   }
   // Passing values to smtp object
   smtp.Send(fromAddress, toAddress, subject, body);
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 197
1 Sergey Alexandrovich Kryukov 141
2 chainerlt 110
3 Mika Wendelius 80
4 ppolymorphe 71
0 OriginalGriff 9,070
1 Sergey Alexandrovich Kryukov 8,413
2 CPallini 5,189
3 Maciej Los 4,746
4 Mika Wendelius 3,676


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100