private SendAsync ( string from, string recipients, string subject, string body, object userToken ) : void | ||
from | string | |
recipients | string | |
subject | string | |
body | string | |
userToken | object | |
Результат | void |
public void SendAsync(string from, string recipients, string subject, string body, object userToken)
{
if (_disposed)
{
throw new ObjectDisposedException(GetType().FullName);
}
SendAsync(new MailMessage(from, recipients, subject, body), userToken);
}
SmtpClient::SendAsync ( |
public void sendEmail(String targetEmail, String targetName, String targetLogin, String password) { String body; body = "Dear " + targetName + ", \n\n"; body += "Thank you for using our application! \n"; body += "Below is your authentication information: \n\n"; body += "\t Your login: "******"\n"; body += "\t Your new password: "******"\n\n"; body += "----------------\n"; body += "Sincerely, Software Development Team"; try { SmtpClient client = new SmtpClient("smtp.gmail.com"); client.Port = 587; client.EnableSsl = true; client.Timeout = 100000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential( "*****@*****.**", "humber123"); MailMessage msg = new MailMessage(); msg.To.Add(targetEmail); msg.From = new MailAddress("*****@*****.**"); msg.Subject = "NEW PASSWORD REQUEST"; msg.Body = body; client.SendAsync(msg, "message"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }