using System.Web.Mail; failed

  • Thread starter Thread starter Jason Zhang
  • Start date Start date
J

Jason Zhang

Hi all,
I have installed VS.net 2003 fully.
When I create a C# project and write a line:using System.Web.Mail;
the IDE complain that the namespace Mail does'nt exist in System.Web.
Why it happens? Dis I miss something?
Thank you!
 
You need to add a reference to the System.Web.dll. The System.Web.Mail
namespace is defined inside that.

Open Solution Explorer, right click the References node of the project
tree, and select Add reference. From the list select System.Web.dll,
press Select and OK. Now you have added a reference to this class
library, and can use it in your project.

-Lenard
 
I don't know why it doesn't work with you.
It works fine with me.
maybe you need to use the fully qualified namespace within your code.
This is what your code should be:
//
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
msg.From = "Sender Mail";
msg.To = "Reception Mail";
msg.Subject = "Message Subject";
masg.Body = "Message Body";
SmtpMail.SmtpServer = "Your MailServer";
SmtpMail.Send(msg);
//

this code should work fine..
let me know if not
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top