Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MailMessage mm = new MailMessage("xyz@gmail.com", TextBoxEmail.Text.Trim());
- mm.Subject = "Password Recovery";
- mm.Body = string.Format("Hi ,<br /><br />Your password is .<br /><br />Thank You.");
- mm.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.EnableSsl = true;
- NetworkCredential NetworkCred = new NetworkCredential();
- NetworkCred.UserName = "xyz@gmail.com";
- NetworkCred.Password = "xyz";
- smtp.UseDefaultCredentials = true;
- smtp.Credentials = NetworkCred;
- smtp.Port = 587;
- smtp.Send(mm);
- message = "Registration successful. Activation email has been sent.";
- ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + message + "');", true);
- using (MailMessage mail = new MailMessage())
- {
- mail.From = new MailAddress("xyz@gmail.com");
- mail.Subject = "mailSubject";
- mail.Body = "mailBody";
- mail.IsBodyHtml = true;
- mail.To.Add("xyz@gmail.com");
- using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))//2nd parameter is PORT No.
- {
- smtp.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "xyz");
- smtp.EnableSsl = true;//set this as your Host Name properties, for gmail,its true
- smtp.Send(mail);//actual sending operation here
- }
- }
- using System.Net;
- using System.Net.Mail;
- var fromAddress = new MailAddress("from@gmail.com", "From Name");
- var toAddress = new MailAddress("to@example.com", "To Name");
- const string fromPassword = "fromPassword";
- const string subject = "Subject";
- const string body = "Body";
- var smtp = new SmtpClient
- {
- Host = "smtp.gmail.com",
- Port = 587,
- EnableSsl = true,
- DeliveryMethod = SmtpDeliveryMethod.Network,
- UseDefaultCredentials = false,
- Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
- };
- using (var message = new MailMessage(fromAddress, toAddress)
- {
- Subject = subject,
- Body = body
- })
- {
- smtp.Send(message);
- }
Add Comment
Please, Sign In to add comment