Hi,
The code is:
try { MailMessage message = new MailMessage(); SmtpClient client = new SmtpClient();
if (this.txtUserName.Text.Trim().Length > 0)
{
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(this.txtUserName.Text.Trim(), this.txtPassword.Text.Trim());
client.Credentials = SMTPUserInfo;
}
message.From = new MailAddress(this.txtFrom.Text.Trim());
message.To.Add(new MailAddress(this.txtTo.Text.Trim()));
message.Subject = this.txtTitle.Text.Trim();
message.Body = this.txtContent.Text.Trim() + "\r\nSMTP Server: " + this.txtSMTPServer.Text.Trim() + "\r\nOrigins: " + Environment.MachineName;
client.Host = this.txtSMTPServer.Text.Trim();
client.SendAsync(message, "Token");
this.lblMessages.Text = "Sending message...";
message.Dispose();
client = null;
GC.Collect();
return;
}
catch (Exception ex)
{
this.lblMessages.Text = this.lblMessages.Text + "\r\nError occured\r\n" + ex.ToString();
return;
}
It returns no errors however I found an audit failure of type Sensitive Privilege Use in the security audit. I assume that this is preventing the mail to go out.
Test with non .NET based apps send out the mail without issues.
Any iadeas?