Help - Failure sending email

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;


}
 
M

Mark Rae

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top