Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 10th, 2004, 06:11 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Default 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.
Reply With Quote
  #2 (permalink)  
Old October 29th, 2004, 11:15 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

System.Web.Mail is part of the .NET framework.

How are you building this application?
Reply With Quote
  #3 (permalink)  
Old January 13th, 2006, 04:31 AM
Authorized User
 
Join Date: Aug 2003
Location: Brisbane, Queensland, Australia.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?


Reply With Quote
  #4 (permalink)  
Old January 13th, 2006, 10:03 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
Reply With Quote
  #5 (permalink)  
Old January 15th, 2006, 06:05 PM
Authorized User
 
Join Date: Aug 2003
Location: Brisbane, Queensland, Australia.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.


Reply With Quote
  #6 (permalink)  
Old January 15th, 2006, 06:36 PM
Authorized User
 
Join Date: Aug 2003
Location: Brisbane, Queensland, Australia.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.



Reply With Quote
  #7 (permalink)  
Old January 16th, 2006, 12:16 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
Reply With Quote
  #8 (permalink)  
Old January 22nd, 2006, 01:23 AM
Authorized User
 
Join Date: Aug 2003
Location: Brisbane, Queensland, Australia.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!

Reply With Quote
  #9 (permalink)  
Old January 22nd, 2006, 01:33 AM
Authorized User
 
Join Date: Aug 2003
Location: Brisbane, Queensland, Australia.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!


Reply With Quote
  #10 (permalink)  
Old January 22nd, 2006, 11:21 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Web.Caching.Cache Error TrivediVishal ASP.NET 1.0 and 1.1 Basics 2 December 18th, 2006 06:58 PM
error system.web....... anpham ASP.NET 1.0 and 1.1 Basics 3 July 1st, 2005 01:36 PM
System.Web.Mail dkb General .NET 3 August 25th, 2004 07:36 AM



All times are GMT -4. The time now is 06:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.