DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Using system.web.dll

  1. #1
    Join Date
    Dec 2005

    Cool Using system.web.dll

    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 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
    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 = ""
    TextBox12.Text = ""
    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)
    End If

    SmtpMail.SmtpServer = sMailServer

    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



  2. #2
    Join Date
    Nov 2003
    Portland, OR
    See if this helps:
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Assembly: System.Web.dll Problem
    By Marco in forum .NET
    Replies: 1
    Last Post: 07-07-2003, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center