473,750 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Textbox1.Text=" hu************@ yahoo.com"
TextBox2.Text=" Husam"
TextBox3.Text=" hu***********@g mail.com"
TextBox4.Text=" dw***@msn.com"
TextBox5.Text=" Test Mail"
TextBox6.Text=" The New E-mail Sender is working well"
TextBox7.Text = "C:\husam.d oc"
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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, sUrlContentLoca tion As String
Dim iLoop1 As Integer

sTo = Trim(TextBox1.T ext)
sFrom = Trim(TextBox2.T ext)
sCc = Trim(TextBox3.T ext)
sBcc = Trim(TextBox4.T ext)
sSubject = Trim(TextBox5.T ext)
sBody = Trim(TextBox6.T ext)
sAttach = Trim(TextBox7.T ext)
sBodyEncoding = Trim(TextBox8.T ext)
sBodyFormat = Trim(TextBox9.T ext)
sPriority = Trim(TextBox10. Text)
sUrlContentBase = Trim(TextBox11. Text)
sUrlContentLoca tion = 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.UrlConte ntBase = sUrlContentBase
MyMail.UrlConte ntLocation = sUrlContentLoca tion

Select Case TextBox8.Text
Case Encoding.UTF7.E ncodingName : MyMail.BodyEnco ding =
Encoding.UTF7
Case Encoding.UTF8.E ncodingName : MyMail.BodyEnco ding =
Encoding.UTF8
Case Else : MyMail.BodyEnco ding = Encoding.ASCII
End Select

Select Case UCase(sBodyForm at)
Case "HTML" : MyMail.BodyForm at = MailFormat.Html
Case Else : MyMail.BodyForm at = MailFormat.Text
End Select

Select Case UCase(sPriority )
Case "HIGH" : MyMail.Priority = MailPriority.Hi gh
Case "LOW" : MyMail.Priority = MailPriority.Lo w
Case Else : MyMail.Priority = MailPriority.No rmal
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(d elim)
Dim myAttachment As MailAttachment = New
MailAttachment( sSubstr)
MyMail.Attachme nts.Add(myAttac hment)
Next
End If

SmtpMail.SmtpSe rver = sMailServer
SmtpMail.Send(M yMail)

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.Htt pException' 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 3891
Do you have a reference to the Collabrative Data Objects (CDO) library?

"Husam" <Hu***@discussi ons.microsoft.c om> wrote in message
news:73******** *************** ***********@mic rosoft.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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Textbox1.Text=" hu************@ yahoo.com"
TextBox2.Text=" Husam"
TextBox3.Text=" hu***********@g mail.com"
TextBox4.Text=" dw***@msn.com"
TextBox5.Text=" Test Mail"
TextBox6.Text=" The New E-mail Sender is working well"
TextBox7.Text = "C:\husam.d oc"
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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, sUrlContentLoca tion As String
Dim iLoop1 As Integer

sTo = Trim(TextBox1.T ext)
sFrom = Trim(TextBox2.T ext)
sCc = Trim(TextBox3.T ext)
sBcc = Trim(TextBox4.T ext)
sSubject = Trim(TextBox5.T ext)
sBody = Trim(TextBox6.T ext)
sAttach = Trim(TextBox7.T ext)
sBodyEncoding = Trim(TextBox8.T ext)
sBodyFormat = Trim(TextBox9.T ext)
sPriority = Trim(TextBox10. Text)
sUrlContentBase = Trim(TextBox11. Text)
sUrlContentLoca tion = 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.UrlConte ntBase = sUrlContentBase
MyMail.UrlConte ntLocation = sUrlContentLoca tion

Select Case TextBox8.Text
Case Encoding.UTF7.E ncodingName : MyMail.BodyEnco ding =
Encoding.UTF7
Case Encoding.UTF8.E ncodingName : MyMail.BodyEnco ding =
Encoding.UTF8
Case Else : MyMail.BodyEnco ding = Encoding.ASCII
End Select

Select Case UCase(sBodyForm at)
Case "HTML" : MyMail.BodyForm at = MailFormat.Html
Case Else : MyMail.BodyForm at = MailFormat.Text
End Select

Select Case UCase(sPriority )
Case "HIGH" : MyMail.Priority = MailPriority.Hi gh
Case "LOW" : MyMail.Priority = MailPriority.Lo w
Case Else : MyMail.Priority = MailPriority.No rmal
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(d elim)
Dim myAttachment As MailAttachment = New
MailAttachment( sSubstr)
MyMail.Attachme nts.Add(myAttac hment)
Next
End If

SmtpMail.SmtpSe rver = sMailServer
SmtpMail.Send(M yMail)

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.Htt pException' 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***@discussi ons.microsoft.c om> 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.Htt pException' occurred in
system.web.dll

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


Did you already take a look at <URL:http://www.systemwebma il.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
8235
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 the automation features provided by the Excel.Application component. The Excel workbooks/documents are stored locally before I call my SendExcelDocument() method in order to attatch each document to an instance of
9
4311
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, VisualStudio2002, VB as programing language. Our test/development version of the web app as hosted on our "localhost" works fine; our "Default SMTP Virtual Server" is running (per the IIS console).
5
2151
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
17205
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, process and output to the screen in my application when a message arrived. But the problem is how do I read the SMS message immediately when it arrived without my handphone BeEPINg for new message ? I read up the AT commands, but when getting down...
1
8182
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 the members of my organization. I think my problem is incorrectly setting the settings on my server or an authentication problem. Here is the code I have written to send a test message: -----Code Begins: Sensitive Information Replaced by -----...
2
3498
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 application, and also succeeds from the asp.net page with BodyFormat=MailFormat.Text. I've recently upgraded from W2K SP4 to WinXP SP2 and am using .Net Framework v1.1 SP1. The code worked fine under W2K SP4.
4
7683
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. But sometimes even when I'm just sending one e-mail the web page takes a minutes or so to post. Can anyone tell me why it is so slow, or how to fix the problem? To address this I am thinking of just creating a queue table to write the emails...
4
17478
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 easily be translated into C#.NET. Storing Email Credentials If you are developing a web application the best place to store your email credentials is in your web.config file's <appSettings>. This will allow you to secure your email credentials using...
7
22874
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 outlook or outlook express it works fine.. System.Net.Mail.MailMessage msgMail = new System.Net.Mail.MailMessage("myemail@mydomain.com", "testemail@mydomain.com", "subject", "message body");
11
3510
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
9001
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9583
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...
0
9396
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
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
8263
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...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4716
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...
0
4888
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.