ASP.net mail

Hello,

I'm trying to get an ASP.net web application to send email. I've seen several problems in the forums relating to this, but my problem hasn't been solved by reading them. Here's (essentially) the code:

Code:
MailMessage msg = new MailMessage();

msg.To = "[email protected]";
msg.From = "[email protected]";
msg.Subject = "A Subject";
msg.BodyFormat = MailFormat.Html;
msg.Body = "<html><body>...and such...</body></html>";

try
{
	SmtpMail.SmtpServer = "localhost";
	SmtpMail.Send(msg);
}
catch (Exception e)
{
	return false;
}
return true;

The function that this code is inside of is returning true when called, however, the email never arrives at the hotmail account. When I send the email to me@mydomain (the same domain that the asp.net app is on), the email comes through just fine.

I've tried using smtp authentication when sending also, but with the same result...

Code:
msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "[email protected]";
msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "password";

Any ideas as to what might be causing the email to not be sent with no errors reported?
 
Eminence1 said:
Hello,

I'm trying to get an ASP.net web application to send email. I've seen several problems in the forums relating to this, but my problem hasn't been solved by reading them.

Any ideas as to what might be causing the email to not be sent with no errors reported?

I think SmtpMail.SmtpServer must be mail.yourdomain.com, but I could be wrong. I have seen many conflicting posts here, some saying to use mail.yourdomain.com and some saying to use localhost. My pages are using mail.yourdomain.com and they seem to be working fine. Try it and see if it works for you.

riley
 
Well, I can't explain it, but it seems to be working now with "mail.mydomain.com". I thought I had tried it this way before, but perhaps not. Thanks for your help.
 
Back
Top