Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MailAddress to = new MailAddress(errorEmailTo);
- MailAddress from = new MailAddress(mailFrom);
- using (MailMessage mail = new MailMessage(from.Address, to.Address))
- {
- SmtpClient client = new SmtpClient();
- NetworkCredential credentials = new NetworkCredential(mailUser, mailPassword);
- try
- {
- client.Host = mailHost;
- client.Port = port;
- if (enableSSL == "Y")
- {
- client.EnableSsl = true;
- }
- client.UseDefaultCredentials = false;
- client.Credentials = credentials;
- //client.DeliveryMethod = SmtpDeliveryMethod.Network;
- mail.Subject = "Test Message. Client ID: " + clientID;
- mail.Body = "Please find the message from BTC Client ID Title: "
- + clientIDTitle
- + " "
- + msg;
- client.Send(mail);
- MessageBox.Show("Sent email to " + errorEmailTo + "n Enable SSL = " + enableSSL);
- button1.BackColor = Color.GreenYellow;
- }
- catch (Exception ex)
- {
- button1.BackColor = Color.Red;
- MessageBox.Show("ERROR. Cannot send email to " + errorEmailTo + " Error Message: " + ex.Message
- + "nEnable SSL = " + enableSSL
- + "nExc. Type = " + ex.GetType().ToString()
- + "nStack Trace = " + ex.StackTrace
- + "n");
- }
- }
- ERROR. Cannot send email to xxxx Error Message: Failure sending mail.
- Enable SSL = Y
- Exc. Type = System.Net.Mail.SmtpException
- Stack Trace = at System.Net.Mail.SmtpClient.Send(MailMessage message)
- at BTCClientUtilities.Form1.SendEmailTo(String errorEmailTo, String msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement