473,698 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Web.Mail namespace?

Hello, I'm trying to create a basic SMTP mail sender using that code,
i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
(system.web.MAI L)

I'm only allowed to declare under that namespaces with "system.web ":

System.Wb.AspNe tHostingPermiss ion
System.Web.AspN etHostingPermis sionAttribute
System.Web.AspN etHostingPermis sionLevel
Imports System.Web.mail
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click

Try
Dim insMail As New System.()
With insMail
.From = "om***********@ gmail.com"
.To = "om***********@ gmail.com"
.Subject = "test"
.Body = "test sending email"
End With
SmtpMail.SmtpSe rver = "your smtp server"
SmtpMail.Send(i nsMail)
Console.WriteLi ne("Successfull y sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
"Error")
End Try
End Sub
However, is there a limitation for "express" version or is there
something wrong about coding?

Thanks...

Oct 19 '07 #1
12 4140
kimiraikkonen <ki************ *@gmail.comwrot e in
news:11******** *************@k 35g2000prh.goog legroups.com:
Imports System.Web.mail
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click

Try
Dim insMail As New System.()
With insMail
.From = "om***********@ gmail.com"
.To = "om***********@ gmail.com"
.Subject = "test"
.Body = "test sending email"
End With
SmtpMail.SmtpSe rver = "your smtp server"
SmtpMail.Send(i nsMail)
Console.WriteLi ne("Successfull y sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
"Error")
End Try
End Sub
However, is there a limitation for "express" version or is there
something wrong about coding?
What problem are you having?

Are you having trouble connecting to your SMTP server?

Oct 19 '07 #2
On Oct 19, 11:30 pm, Spam Catcher <spamhoney...@r ogers.comwrote:
kimiraikkonen <kimiraikkone.. .@gmail.comwrot e innews:11****** *************** @k35g2000prh.go oglegroups.com:
Imports System.Web.mail
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
Try
Dim insMail As New System.()
With insMail
.From = "omar.abid2...@ gmail.com"
.To = "omar.abid2...@ gmail.com"
.Subject = "test"
.Body = "test sending email"
End With
SmtpMail.SmtpSe rver = "your smtp server"
SmtpMail.Send(i nsMail)
Console.WriteLi ne("Successfull y sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
"Error")
End Try
End Sub
However, is there a limitation for "express" version or is there
something wrong about coding?

What problem are you having?

Are you having trouble connecting to your SMTP server?
No, i get some error messages from Vb.net 2005 "express" starting with
"'Imports' statements must precede any declarations" continues with
other errors about declerations (e.g.insmail, smtpmail) as well.

Sorry for being beginner.

thanks...

Oct 19 '07 #3
kimiraikkonen <ki************ *@gmail.comwrot e in
news:11******** **************@ z24g2000prh.goo glegroups.com:
No, i get some error messages from Vb.net 2005 "express" starting with
"'Imports' statements must precede any declarations" continues with
other errors about declerations (e.g.insmail, smtpmail) as well.

Sorry for being beginner.

thanks...
Imports should go at the very top of your class file.

Imports System.Web.Mail
Public Class....
Your Function Here

End Class
Oct 19 '07 #4
On Fri, 19 Oct 2007 13:26:03 -0700, kimiraikkonen
<ki************ *@gmail.comwrot e:
>Hello, I'm trying to create a basic SMTP mail sender using that code,
i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
(system.web.MA IL)

I'm only allowed to declare under that namespaces with "system.web ":

System.Wb.AspN etHostingPermis sion
System.Web.Asp NetHostingPermi ssionAttribute
System.Web.Asp NetHostingPermi ssionLevel
Imports System.Web.mail
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click

Try
Dim insMail As New System.()
With insMail
.From = "om***********@ gmail.com"
.To = "om***********@ gmail.com"
.Subject = "test"
.Body = "test sending email"
End With
SmtpMail.SmtpSe rver = "your smtp server"
SmtpMail.Send(i nsMail)
Console.WriteLi ne("Successfull y sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
"Error")
End Try
End Sub
However, is there a limitation for "express" version or is there
something wrong about coding?

Thanks...
In the .NET framework 2 the MailMessage class is in the
System.Net.Mail namespace

--
http://bytes.thinkersroom.com
Oct 19 '07 #5
On Oct 19, 11:50 pm, "Rad [Visual C# MVP]" <r...@nospam.co mwrote:
On Fri, 19 Oct 2007 13:26:03 -0700, kimiraikkonen

<kimiraikkone.. .@gmail.comwrot e:
Hello, I'm trying to create a basic SMTP mail sender using that code,
i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
(system.web.MAI L)
I'm only allowed to declare under that namespaces with "system.web ":
System.Wb.AspNe tHostingPermiss ion
System.Web.AspN etHostingPermis sionAttribute
System.Web.AspN etHostingPermis sionLevel
Imports System.Web.mail
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
Try
Dim insMail As New System.()
With insMail
.From = "omar.abid2...@ gmail.com"
.To = "omar.abid2...@ gmail.com"
.Subject = "test"
.Body = "test sending email"
End With
SmtpMail.SmtpSe rver = "your smtp server"
SmtpMail.Send(i nsMail)
Console.WriteLi ne("Successfull y sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn' t send mail", MsgBoxStyle.Cri tical,
"Error")
End Try
End Sub
However, is there a limitation for "express" version or is there
something wrong about coding?
Thanks...

In the .NET framework 2 the MailMessage class is in the
System.Net.Mail namespace

--http://bytes.thinkersr oom.com
Thanks, that's true! But still i get decleration errors about
"insmail", "smtpmail" syntaxes due to not being .net 2.0 classes. What
should be the exact ones?

Thanks!

Oct 19 '07 #6
Ok, however i managed to configure some code OK.

Imports System.Net.Mail
Public Class Form1

Protected Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click
Try
Dim message As New MailMessage(txt To.Text, txtFrom.Text,
txtSubject.Text , txtBody.Text)
Dim emailClient As New SmtpClient(txtS MTPServer.Text)
emailClient.Sen d(message)
litStatus.Text = "Message Sent"

Catch ex As Exception
MsgBox("error")
End Try

End Sub

End Class

But i get "error" message because my smtp server needs authentication
(username, password).
How can i set these?

Thanks.

Oct 19 '07 #7
However, added that authorization codes OK
but i get still "error" message for some reason.
Dim SMTPUserInfo As New System.Net.Netw orkCredential(t xtSMTPUser.Text ,
txtSMTPPass.Tex t)
emailClient.Use DefaultCredenti als = False
emailClient.Cre dentials = SMTPUserInfo

Is there a reliable and FREE Smtp server to test?


Oct 19 '07 #8
Kimi,

Click the menu Projects -Add References -Select in the .Net box the
"System.Net.Mai l"

Set that import as is written in the other messages (to System.Net.Mail )
and it should have to work.

Cor

Oct 20 '07 #9
"kimiraikko nen" <ki************ *@gmail.comschr ieb:
Hello, I'm trying to create a basic SMTP mail sender using that code,
i'm using VB.NET 2005 "express" but this namespace wasn't recognized...
(system.web.MAI L)
Make sure your project contains a reference to "System.Web.dll ".

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Oct 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3086
by: Chris | last post by:
Hi, We have the latest version of Visual Studio installed on two machines. Both give an error when trying to use System.Web.Mail "The type or namespace name 'Mail' does not exist in the class or namespace 'System.Web' (are you missing an assembly reference?)" According to the microsoft examples & the help this should be there.
4
4741
by: Andreas von Linden | last post by:
Hello all, i'am using VS .NET 2003 Prof (new installed with .NET 1.1) on WinXP Prof (SP2). I need to programm an small SMTP Client in C#. When i try using System.Web.Mail i get the Errormsg that the Namespace Mail does not exist in System.Web I can't see any System.Web.Mail.dll in the .NET Framework installation dir.
3
2099
by: Eric | last post by:
When I use system.web.mail namespace in most of my integration programs and in windows application programs it doesn't work. it normally gives an exception "Could not access 'CDO.Message' object." or "Could not access MAPI drivers". (all these machines, outlook is not installed and local SMTP is installed and delivery configured to relay to the mail server. all my win32 services runs under administrator.) I was under the impression that...
3
3265
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From = "W-MyPcName.mycompany.com"; mail.To=strTo; mail.Cc=strCC; mail.Bcc=strBCC;
5
2234
by: martin | last post by:
Hi, I have created a class that is totally seperate from my web application. However this class is used extensivly by the web application for stuff like data access. I wish to add a function to this class that will send email, however my class will not seem to recognise the system.web.mail.mailmessage. my first impression on this is that I may have to use some sort of third
6
5803
by: VB Programmer | last post by:
I'm trying to send an email from my VB.NET application. From the examples I've seen everyone imports 'System.Web.Mail' first. But, when I type 'import System.Web.Mail' the editor says it can't find the namespace. The message is: "Namespace or type 'mail' for the Imports 'System.Web.Mail' cannot be found." Any ideas? Thanks.
1
3891
by: John Hamilton | last post by:
I am writing a client app that communicates with a legacy system via email. The legacy system uses very primative mail messaging and thus doesn't support MIME or Base64 Encoded attachments. Since System.Web.Mail is supposed to be deprecated my client is using System.Net.Mail. I cannot for the life of me find a way to create a mail message without any MIME headers but most of all there is no way to select UUEncoding for Attachment...
10
3954
by: Frank | last post by:
Hi, I am hoping to find out the differences between the System.Net.Mail and System.Web.Mail. Can some nice folks post the differences; or some urls which show the differences? Great Thanks Frank
11
3503
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and older community. I need help expanding the programs capabilities. Searching this forum I did not find any related information so if I have chosen poorly, I would appreciate a suggestion of a more appropriate dotnet forum. Now what I wish is the ability to send bcc's rather than to: (would be...
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4361
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.