brgdotnet
asked on
How to send an email message from "LocalHost" using C# and Asp.Net
I have written some C# code to send out an email message from a server. I can not get it to work off of my local machine. Attached is a code snippet. Does anyone have any ideas what the problem is?
// This is in the web.config -> <add key="wireUp_SMTPServer" value="localhost"/>
protected string smtpServerStr = ConfigurationSettings.AppSettings["wireUp_SMTPServer"];
StringBuilder strMsg = new StringBuilder();
strMsg.Append("Hello this is a test");
MailMessage myEmailObject = new MailMessage();
myEmailObject.To = strToEmail; // Email address not shown here
myEmailObject.From = areunMailStr;
myEmailObject.Subject = "Welcome to our site";
myEmailObject.Body = strMsg.ToString();
myEmailObject.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = smtpServerStr;
try
{
SmtpMail.Send(myEmailObject);
return true;
}
catch
{
return false;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER