473,326 Members | 2,061 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,326 software developers and data experts.

Using System.web.dll to send mail ?

Hi EveryBody:

I made windows application project as e-mail sender. This project consist of
13 textbox and one label and one button. I add {system.web.dll} as refrance
to this project to help me using some mail functions after I got hint from
Mr. Paul Remblance to do so.

The code is like the follwoing:

Imports System.Web.Mail
Imports System.Text

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Textbox1.Text="hu************@yahoo.com"
TextBox2.Text="Husam"
TextBox3.Text="hu***********@gmail.com"
TextBox4.Text="dw***@msn.com"
TextBox5.Text="Test Mail"
TextBox6.Text="The New E-mail Sender is working well"
TextBox7.Text = "C:\husam.doc"
TextBox8.Text = Encoding.ASCII.EncodingName
TextBox9.Text = "HTML"
TextBox10.Text = "Normal"
TextBox11.Text = "http://www.yahoo.com/"
TextBox12.Text = "http://www.yahoo.com/"
TextBox13.Text = "yahoo"

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sTo As String, sFrom As String, sSubject As String, sBody As
String
Dim sCc As String, sBcc As String
Dim sAttach As String, sBodyEncoding As String
Dim sBodyFormat As String, sMailServer As String, sPriority As String
Dim sUrlContentBase As String, sUrlContentLocation As String
Dim iLoop1 As Integer

sTo = Trim(TextBox1.Text)
sFrom = Trim(TextBox2.Text)
sCc = Trim(TextBox3.Text)
sBcc = Trim(TextBox4.Text)
sSubject = Trim(TextBox5.Text)
sBody = Trim(TextBox6.Text)
sAttach = Trim(TextBox7.Text)
sBodyEncoding = Trim(TextBox8.Text)
sBodyFormat = Trim(TextBox9.Text)
sPriority = Trim(TextBox10.Text)
sUrlContentBase = Trim(TextBox11.Text)
sUrlContentLocation = Trim(TextBox12.Text)
sMailServer = Trim(TextBox13.Text)

Dim MyMail As MailMessage = New MailMessage

MyMail.From = sFrom
MyMail.To = sTo
MyMail.Subject = sSubject
MyMail.Body = sBody
MyMail.Cc = sCc
MyMail.Bcc = sBcc
MyMail.UrlContentBase = sUrlContentBase
MyMail.UrlContentLocation = sUrlContentLocation

Select Case TextBox8.Text
Case Encoding.UTF7.EncodingName : MyMail.BodyEncoding =
Encoding.UTF7
Case Encoding.UTF8.EncodingName : MyMail.BodyEncoding =
Encoding.UTF8
Case Else : MyMail.BodyEncoding = Encoding.ASCII
End Select

Select Case UCase(sBodyFormat)
Case "HTML" : MyMail.BodyFormat = MailFormat.Html
Case Else : MyMail.BodyFormat = MailFormat.Text
End Select

Select Case UCase(sPriority)
Case "HIGH" : MyMail.Priority = MailPriority.High
Case "LOW" : MyMail.Priority = MailPriority.Low
Case Else : MyMail.Priority = MailPriority.Normal
End Select

' Build an IList of mail attachments.
If sAttach <> "" Then
Dim delim As Char = ","
Dim sSubstr As String
For Each sSubstr In sAttach.Split(delim)
Dim myAttachment As MailAttachment = New
MailAttachment(sSubstr)
MyMail.Attachments.Add(myAttachment)
Next
End If

SmtpMail.SmtpServer = sMailServer
SmtpMail.Send(MyMail)

Label1.Text = "VB Message sent to " & MyMail.To

End Sub

When I debug this project And I connect to the net and I press the button
which is send button I got an error message which said the follwoing:

An unhandled exception of type 'System.Web.HttpException' occurred in
system.web.dll

Additional information: Could not access 'CDO.Message' object.

So any one can give me hint or redirection to solve this problem ?

Any help will be appreciated

regard's



Jan 1 '06 #1
2 3872
Do you have a reference to the Collabrative Data Objects (CDO) library?

"Husam" <Hu***@discussions.microsoft.com> wrote in message
news:73**********************************@microsof t.com...
Hi EveryBody:

I made windows application project as e-mail sender. This project consist
of
13 textbox and one label and one button. I add {system.web.dll} as
refrance
to this project to help me using some mail functions after I got hint from
Mr. Paul Remblance to do so.

The code is like the follwoing:

Imports System.Web.Mail
Imports System.Text

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Textbox1.Text="hu************@yahoo.com"
TextBox2.Text="Husam"
TextBox3.Text="hu***********@gmail.com"
TextBox4.Text="dw***@msn.com"
TextBox5.Text="Test Mail"
TextBox6.Text="The New E-mail Sender is working well"
TextBox7.Text = "C:\husam.doc"
TextBox8.Text = Encoding.ASCII.EncodingName
TextBox9.Text = "HTML"
TextBox10.Text = "Normal"
TextBox11.Text = "http://www.yahoo.com/"
TextBox12.Text = "http://www.yahoo.com/"
TextBox13.Text = "yahoo"

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sTo As String, sFrom As String, sSubject As String, sBody As
String
Dim sCc As String, sBcc As String
Dim sAttach As String, sBodyEncoding As String
Dim sBodyFormat As String, sMailServer As String, sPriority As
String
Dim sUrlContentBase As String, sUrlContentLocation As String
Dim iLoop1 As Integer

sTo = Trim(TextBox1.Text)
sFrom = Trim(TextBox2.Text)
sCc = Trim(TextBox3.Text)
sBcc = Trim(TextBox4.Text)
sSubject = Trim(TextBox5.Text)
sBody = Trim(TextBox6.Text)
sAttach = Trim(TextBox7.Text)
sBodyEncoding = Trim(TextBox8.Text)
sBodyFormat = Trim(TextBox9.Text)
sPriority = Trim(TextBox10.Text)
sUrlContentBase = Trim(TextBox11.Text)
sUrlContentLocation = Trim(TextBox12.Text)
sMailServer = Trim(TextBox13.Text)

Dim MyMail As MailMessage = New MailMessage

MyMail.From = sFrom
MyMail.To = sTo
MyMail.Subject = sSubject
MyMail.Body = sBody
MyMail.Cc = sCc
MyMail.Bcc = sBcc
MyMail.UrlContentBase = sUrlContentBase
MyMail.UrlContentLocation = sUrlContentLocation

Select Case TextBox8.Text
Case Encoding.UTF7.EncodingName : MyMail.BodyEncoding =
Encoding.UTF7
Case Encoding.UTF8.EncodingName : MyMail.BodyEncoding =
Encoding.UTF8
Case Else : MyMail.BodyEncoding = Encoding.ASCII
End Select

Select Case UCase(sBodyFormat)
Case "HTML" : MyMail.BodyFormat = MailFormat.Html
Case Else : MyMail.BodyFormat = MailFormat.Text
End Select

Select Case UCase(sPriority)
Case "HIGH" : MyMail.Priority = MailPriority.High
Case "LOW" : MyMail.Priority = MailPriority.Low
Case Else : MyMail.Priority = MailPriority.Normal
End Select

' Build an IList of mail attachments.
If sAttach <> "" Then
Dim delim As Char = ","
Dim sSubstr As String
For Each sSubstr In sAttach.Split(delim)
Dim myAttachment As MailAttachment = New
MailAttachment(sSubstr)
MyMail.Attachments.Add(myAttachment)
Next
End If

SmtpMail.SmtpServer = sMailServer
SmtpMail.Send(MyMail)

Label1.Text = "VB Message sent to " & MyMail.To

End Sub

When I debug this project And I connect to the net and I press the button
which is send button I got an error message which said the follwoing:

An unhandled exception of type 'System.Web.HttpException' occurred in
system.web.dll

Additional information: Could not access 'CDO.Message' object.

So any one can give me hint or redirection to solve this problem ?

Any help will be appreciated

regard's



Jan 1 '06 #2
"Husam" <Hu***@discussions.microsoft.com> schrieb:
I made windows application project as e-mail sender. This project consist
of
13 textbox and one label and one button. I add {system.web.dll} as
refrance
to this project
[...]
An unhandled exception of type 'System.Web.HttpException' occurred in
system.web.dll

Additional information: Could not access 'CDO.Message' object.


Did you already take a look at <URL:http://www.systemwebmail.net/>?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 2 '06 #3

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

Similar topics

1
by: Trond A. S. Andersen | last post by:
Hi all, I'm working on a project in which i need to send mail attachments in the form of Excel documents from a .NET C# application. I've written a class which creates the Excel document using...
9
by: Bob Jones | last post by:
We have developed a commercial ASP.net application (personal nutrition management and tracking); we want to send smtp email from within it. For our development box, we use WinXP Pro, IIS 5.5,...
5
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. ...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console...
4
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. ...
4
Frinavale
by: Frinavale | last post by:
Introduction Many .NET applications will require an email be sent out for various reasons. This article will give a quick examples on how to send an email using VB.NET. The examples given can...
7
by: Rob Dob | last post by:
The following code is giving me a timeout problem., no matter what I do I can't send a piece of mail using .net2.0 System.Net.Mail.SmtpClient via port 465 and using ssl, if however I try using...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.