473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.MAIL)

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

System.Wb.AspNetHostingPermission
System.Web.AspNetHostingPermissionAttribute
System.Web.AspNetHostingPermissionLevel
Imports System.Web.mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) 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.SmtpServer = "your smtp server"
SmtpMail.Send(insMail)
Console.WriteLine("Successfully sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn't send mail", MsgBoxStyle.Critical,
"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 4111
kimiraikkonen <ki*************@gmail.comwrote in
news:11*********************@k35g2000prh.googlegro ups.com:
Imports System.Web.mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) 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.SmtpServer = "your smtp server"
SmtpMail.Send(insMail)
Console.WriteLine("Successfully sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn't send mail", MsgBoxStyle.Critical,
"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...@rogers.comwrote:
kimiraikkonen <kimiraikkone...@gmail.comwrote innews:11*********************@k35g2000prh.googleg roups.com:
Imports System.Web.mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) 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.SmtpServer = "your smtp server"
SmtpMail.Send(insMail)
Console.WriteLine("Successfully sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn't send mail", MsgBoxStyle.Critical,
"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.comwrote in
news:11**********************@z24g2000prh.googlegr oups.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.comwrote:
>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.MAIL)

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

System.Wb.AspNetHostingPermission
System.Web.AspNetHostingPermissionAttribute
System.Web.AspNetHostingPermissionLevel
Imports System.Web.mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) 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.SmtpServer = "your smtp server"
SmtpMail.Send(insMail)
Console.WriteLine("Successfully sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn't send mail", MsgBoxStyle.Critical,
"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.comwrote:
On Fri, 19 Oct 2007 13:26:03 -0700, kimiraikkonen

<kimiraikkone...@gmail.comwrote:
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.MAIL)
I'm only allowed to declare under that namespaces with "system.web":
System.Wb.AspNetHostingPermission
System.Web.AspNetHostingPermissionAttribute
System.Web.AspNetHostingPermissionLevel
Imports System.Web.mail
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) 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.SmtpServer = "your smtp server"
SmtpMail.Send(insMail)
Console.WriteLine("Successfully sent email message" +
vbCrLf)
Catch err As Exception
MsgBox("Couldn't send mail", MsgBoxStyle.Critical,
"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
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.EventArgs) Handles btnSubmit.Click
Try
Dim message As New MailMessage(txtTo.Text, txtFrom.Text,
txtSubject.Text, txtBody.Text)
Dim emailClient As New SmtpClient(txtSMTPServer.Text)
emailClient.Send(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.NetworkCredential(txtSMTPUser.Text,
txtSMTPPass.Text)
emailClient.UseDefaultCredentials = False
emailClient.Credentials = 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.Mail"

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
"kimiraikkonen" <ki*************@gmail.comschrieb:
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.MAIL)
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
Herfried,
Make sure your project contains a reference to "System.Web.dll".
Not so clever in version 2005 it is obsolete.

Cor

Oct 20 '07 #11
On Fri, 19 Oct 2007 21:44:03 -0000, kimiraikkonen
<ki*************@gmail.comwrote:
>However, added that authorization codes OK
but i get still "error" message for some reason.
Dim SMTPUserInfo As New System.Net.NetworkCredential(txtSMTPUser.Text,
txtSMTPPass.Text)
emailClient.UseDefaultCredentials = False
emailClient.Credentials = SMTPUserInfo

Is there a reliable and FREE Smtp server to test?
How does your SMTP server authenticate you? A quick way to test is
Telneting to the server and trying to login from the telnet session
using the username and password in your code

--
http://bytes.thinkersroom.com
Oct 22 '07 #12
On Oct 22, 11:58 am, "Rad [Visual C# MVP]" <r...@nospam.comwrote:
On Fri, 19 Oct 2007 21:44:03 -0000, kimiraikkonen

<kimiraikkone...@gmail.comwrote:
However, added that authorization codes OK
but i get still "error" message for some reason.
Dim SMTPUserInfo As New System.Net.NetworkCredential(txtSMTPUser.Text,
txtSMTPPass.Text)
emailClient.UseDefaultCredentials = False
emailClient.Credentials = SMTPUserInfo
Is there a reliable and FREE Smtp server to test?

How does your SMTP server authenticate you? A quick way to test is
Telneting to the server and trying to login from the telnet session
using the username and password in your code

--http://bytes.thinkersroom.com
Hello,
I've done by using Gmail free smtp server. Rad, i enabled SSL and
username/passwords as shown above and port 587(not needed
actually)There was no need to add special reference (dll).
"imports System.Net.Mail" done it.

Thanks.

Oct 25 '07 #13

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

Similar topics

3
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...
4
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...
3
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."...
3
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 =...
5
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...
6
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...
1
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. ...
10
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...
11
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.