Trying to build a simple form that allows to send emails.
In the code behind module I have something as simple as this:
private void Button1_Click(object sender, System.EventArgs e)
{
MailMessage Mail = new MailMessage();
Mail.To = "whoever@dotnet.itags.org.whatever.com";
Mail.Cc = "";
Mail.Bcc = "";
Mail.Subject = "This is a test";
Mail.Body = "Will it work this time?";
// Set the property below to a valid email address
Mail.From = "whatever@dotnet.itags.org.whoever.com";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(Mail);
}
And it always gives me the same error:
Exception Details: System.Runtime.InteropServices.COMException: At least one of the From or Sender fields is required, and neither was found.
Seems like I have everything right. My Smtp is properly installed.
Can anyone help me?Hello, when u send an email u need to have
.From ="someone@.address.com"
and the mail smtp as "mail.address.com"
they should be similar can u see the similarity between both fields ? so ur code should be like this:
\private void Button1_Click(object sender, System.EventArgs e)
{
MailMessage Mail = new MailMessage();Mail.To = "whoever@.whatever.com";
Mail.Cc = "";
Mail.Bcc = "";
Mail.Subject = "This is a test";
Mail.Body = "Will it work this time?";// Set the property below to a valid email address
Mail.From = "whatever@.whoever.com";
SmtpMail.SmtpServer = "smtp.whoever.com";
SmtpMail.Send(Mail);
}
Thank you very very much. It worked !!! :))
0 comments:
Post a Comment