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

System.Net.Mail vs System.Web.Mail

P: n/a
I want to use the new System.Net.Mail instead of the old System.Web.Mail.

I'm getting an error "Hot not specified" when I try to do my last two lines:

System.Net.Mail.SmtpClient SMTP = new SmtpClient();
SMTP.Send(Message); //Error happens here
But the thing is, in my old use of System.Web.Mail, I never had this
problem. Why do I HAVE to specify the host in the new version and I didn't
have to in the old?

Alex
Jun 16 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

In oldversion when using System.web.Mail, the SmtpMail class automatically
uses the built-in mail service in Windows 2000. But in new version,
SmtpClient class does not use any default mail service. Hence when using
System.Net.Mail namespace, you need to specify the host.

SmtpClient mailObj = new SmtpClient();
mailObj.Host = "name of the host";

(or)

SmtpClient mailObj = new SmtpClient( "name of the host");
MailMessage mail = new MailMessage("x@yahoo.co.in", "x@hotmail.com",
"Testing", "Hello Everybody");
mailObj.Send(mail);

Regards,
Sharmila

"Alex Maghen" <Al********@newsgroup.nospam> wrote in message
news:93**********************************@microsof t.com...
I want to use the new System.Net.Mail instead of the old System.Web.Mail.

I'm getting an error "Hot not specified" when I try to do my last two
lines:

System.Net.Mail.SmtpClient SMTP = new SmtpClient();
SMTP.Send(Message); //Error happens here
But the thing is, in my old use of System.Web.Mail, I never had this
problem. Why do I HAVE to specify the host in the new version and I didn't
have to in the old?

Alex

Jun 16 '06 #2

P: n/a

Thank you Sharmila for your input.

Hi Alex,

Thank you for your post.

Unlike System.Web.Mail, which was introduced in the 1.0 Framework,
System.Net.Mail is not built upon the CDO/CDOSYS libraries. Instead it is
written from the ground up without any interop. Thus, it is not dependant
upon on other COM libraries. Although some functionality has been removed,
the new System.Net.Mail namespace is much more versatile than the older CDO
dependant System.Web.Mail.

Other than Sharmila's input about specifying the server in code, you can
also config the Host, Credentials and Port properties for SmtpClient by
using the settings in the application or machine configuration files. For
example:

<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
</configuration>

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.