Help - Failure sending email

  • Thread starter Thread starter NW Technicals
  • Start date Start date
N

NW Technicals

I am trying to send email using this fucntion can you guys help me please
finding the mistake

I am using my Gmail Credentials and the only exception error I get is

Failure sending email

Any help is greatly appreciated

=====================

MailMessage mailMessage = new MailMessage();

try

{

SmtpClient client = new SmtpClient();

client.Host = SMPTPServerTextBox.Text.Trim();

string emailUserName = FromAddressEmailTextBox.Text.Trim();

string emailPassword = EmailPasswordTextBox.Text.Trim();

client.Credentials = new NetworkCredential(emailUserName, emailPassword);

client.EnableSsl = true;

string toAddress = ToAddressEmailTextBox.Text.Trim();

mailMessage.To.Add(new MailAddress(toAddress));

mailMessage.From = new MailAddress(emailUserName);

mailMessage.Subject = SubjectTextBox.Text.Trim();

mailMessage.Body = EmailBodyTextBox.Text.Trim();

client.Send(mailMessage);

EmailResultTextBox.Text = "Successfully Send Email";

// Logger.LogInfo("Successfully Sent Email");

}

catch (Exception ex)

{

EmailResultTextBox.Text = ex.Message;


}
 
I am trying to send email using this fucntion can you guys help me please
finding the mistake

I am using my Gmail Credentials and the only exception error I get is

Failure sending email

Any help is greatly appreciated

You need to inspect the InnerException. See here for further details:
http://www.systemnetmail.com
 
Back
Top