By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

problem using SmtpClient to send email from asp.net

P: n/a
Jay
The code below is a recommended way to send email with c# from my aspx page:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("de*********@ziptax.com");
mail.To.Add(new MailAddress(strTo));
mail.Subject = "ZipTax Survey Received";
mail.Body = body;
SmtpClient client = new
SmtpClient(System.Configuration.ConfigurationManag er.AppSettings["SmtpServer"]);
try
{
client.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex);
}

My from, to, subject and body are all populated and not null. But I get the
error below when run from my asp.net host provider:

ERROR: System.ArgumentNullException: Value cannot be null. Parameter name:
value at System.Net.Mail.SmtpClient.set_Host(String value) at
ZipTaxSurvey.Button1_Click(Object sender, EventArgs e)

Can someone please advise?
Thanks,
jay
Mar 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.