I am writing a C# app that uses the SMTP server on my local pc to send email. I can send email normally (throught email client) but mail is not sent using this very simple C# 2.0 code.
No exception is generated
Mail ends up in C:\Inetpub\mailroot\Queue as eml file
Mail not sent - cannot be seen in Outlook after send and recieve clicked to refresh inbox
All email addresses and passwords correct
Here is my code...
No exception is generated
Mail ends up in C:\Inetpub\mailroot\Queue as eml file
Mail not sent - cannot be seen in Outlook after send and recieve clicked to refresh inbox
All email addresses and passwords correct
Here is my code...
Code:
private void btnSend_Click(object sender, EventArgs e){
try
{
MailMessage message = new MailMessage(
"my email address",
"my email address",
"Test Send Subject",
"Test Send Body");
SmtpClient client = new SmtpClient("The name of my mail server in IIS");
System.Net.NetworkCredential cred = new System.Net.NetworkCredential();
cred.UserName = "my email address";
cred.Password = "my email password";
client.UseDefaultCredentials = true;
client.Credentials = cred;
client.Send(message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}