 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 10th, 2004, 06:11 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
|
|
System.Web Error
I want to create a program that can send e-mail. I found code in the help file for sending e-mails in VB.NET.
Code:
System.Web.Mail.SmtpMail.SmtpServer = "SmtpServerName"
System.Web.Mail.SmtpMail.Send( _
"SenderAddress", "RecepientAddress", "SubjectText", "MessageText")
When I pasted this in I got an error saying "Mail" is not a member of "Web". I read further and it said I need a reference to the System.Web.dll file. How do I know if I have the System.Web.Dll file on my computer and how do I create a reference to it?
Thanks in advance.
|
|

October 29th, 2004, 11:15 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
System.Web.Mail is part of the .NET framework.
How are you building this application?
|
|

January 13th, 2006, 04:31 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Right, rank beginner here, and I get the same error.
At the top, right before Public Class Form1, I have
Imports System.IO
Imports System
Imports System.web.Mail
The last line throws the error
Namespace or type "Mail" for the Import 'System.Web.Mail' connot be found.
I am compiling the only way I know, from VB.NET from the Visual Studio .NET
So what else do I need to make it recognise System.Web.Mail, please?
|
|

January 13th, 2006, 10:03 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
From a visual studio project you can add a reference to System.Web. It should be there already if you created a web application within visual studio.
- Peter
|
|

January 15th, 2006, 06:05 PM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Peter. It's a Visual Studio project, not a web application. Can you help me on how to "add a refererence to System.Web" please? I don't follow the idea of 'adding a reference'. How does one do that?
I expect to be able to then "Dim my_email As New System.Web.Mail.MailMessage"
etc.
Cheers, Imre.
|
|

January 15th, 2006, 06:36 PM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks again Peter. After I posted the above, the penny dropped, and I looked at the menu bar. Under Projects was "Add Reference" and I was able to add "System.Web".
Funny, but when I looked at it again the option Add Reference is greyed out. Can't get it back. Weird.
The other thing I can't get my head around is why it didn't import the whole of System, and why I have to mention System.Web explicitly. System.Web is included in the System components revealed in Object Browser.
Thanks again! Imre.
|
|

January 16th, 2006, 12:16 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
First: "It's a Visual Studio project, not a web application." doesn't make sense. You can have a visual studio project that's a web application (or one of several other application types).
Second: Visual studio won't automatically reference more than it absolutely needs based on the application type. If you created a web application, it would have referenced System.Web. There are MANY assemblies it doesn't reference automatically because it doesn't know what you'll need.
- Peter
|
|

January 22nd, 2006, 01:23 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Peter. I appreciate your attempts to explain it. Perhaps I could have said "It's a Visual Studio Project, but not a web application". Would that make sense? I see it as just the ordinary sort of default project. Maybe it is indeed a web application, and I don't know it.
The idea that it won't reference System.Web doesn't make much sense to me either. I see I have to say Imports System and Imports Sytem.IO and it seems to reference that OK. Sorry.
Anyhow it's not throwing the error about Mail any more so I'm pleased. Now I have the next error to worry about, if you have the patience, please. See other post.
Yassou!
|
|

January 22nd, 2006, 01:33 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yo. The next error is this.
An unhandled exception of type 'System.Web.httpException' occurred in system.web.dll.
Additional Information: Could not access 'CDO.Message' object.
I looked up this Collaboration Data Object but none of it was comprehensible to me, or seemed relevant.
I have included the line
System.Web.Mail.SmtpMail.SmtpServer = "smtp.uq.net.au"
which is how I have my email client set up. Does that look right?
Yassou!
|
|

January 22nd, 2006, 11:21 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
That CDO.Message error is quite ambiguous. Usually it means it can't hit the mail server. It could me that mail relay rules is rejecting the message. But that usually shouldn't happen if you are accessing a mail server on a "internal" network. Usually this includes your ISP's mail server because you (being connected to the ISP) are "inside" their network. Or at least you are inside the ISPs segment of the public network. You might have to explore the stack trace further to determine the error.
- Peter
|
|
 |