Results 1 to 13 of 13

Thread: Error in E-mail Code

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    11

    Error in E-mail Code

    I get this message when i use either of the codes at the bottom of this thread, can anyone help me out?

    The coding that is highlighted in the first code is "End With" and the coding that is highlighted in the second code is "System.Web.Mail.SmtpMail.Send(mailMessage)"

    I used to get an error from not having Web.dll as my reference but i fixed that and now this is my problem

    Any Ideas?
    Thanks a lot
    Dan

    Error:

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

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

    Code Used:

    Dim m As New System.Web.Mail.MailMessage()


    With m
    .From = "[email protected]"
    .To = "myself$my.house"
    .Subject = "My SMTP Test"
    .Body = "My New Message"
    End With

    SmtpMail.SmtpServer = "www.digitalims.net"
    SmtpMail.Send(m)


    Or the other code:

    Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()
    mailMessage.From = "[email protected]"
    mailMessage.To = "[email protected]"
    mailMessage.Subject = "Email Subject"
    mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text

    System.Web.Mail.SmtpMail.SmtpServer = "localhost"
    System.Web.Mail.SmtpMail.Send(mailMessage)

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    is this object exist in your code "CDO.Message'" ??

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    11
    CDO.Message appears no where in my code, the code you see is the exact code i used to try and get it to work, All i did was make a form, load Web.dll references to get the second code to work, and made that code proccess with a command button...... CDO.Message is not an object of 'System.Web.HttpException' ? i really have no idea whats going on.....????

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I bet this will work......

    VB Code:
    1. Private Function EmailCust(ByVal Email As String, ByVal msgBody As String) As Boolean
    2.         Dim myMessage As New Mail.MailMessage()
    3.         Dim myMailServer As Mail.SmtpMail
    4.  
    5.         myMessage.To = Email
    6.         myMessage.From = "[email protected]"
    7.         myMessage.Subject = "You subject here"
    8.  
    9.         myMessage.Body = msgBody
    10.  
    11.         myMailServer.SmtpServer = "your mail server here"
    12.         myMailServer.Send(myMessage)
    13.  
    14.         myMessage = Nothing
    15.         Return True
    16.     End Function

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    11
    Ok now i got that code to work right with a little modification
    but how do i get a private function to work as like a command button?
    If i figure this out before you read this i'll post again....
    new code:
    Private Function EmailCust(ByVal Email As String, ByVal msgBody As String) As Boolean
    Dim myMessage As New System.Web.Mail.MailMessage()
    Dim myMailServer As System.Web.Mail.SmtpMail

    myMessage.To = Email
    myMessage.From = "[email protected]"
    myMessage.Subject = "You subject here"

    myMessage.Body = msgBody

    myMailServer.SmtpServer = "www.digitalims.net"
    myMailServer.Send(myMessage)

    myMessage = Nothing
    Return True
    End Function

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by HisAirness
    Ok now i got that code to work right with a little modification
    but how do i get a private function to work as like a command button?
    If i figure this out before you read this i'll post again....
    new code:
    Private Function EmailCust(ByVal Email As String, ByVal msgBody As String) As Boolean
    Dim myMessage As New System.Web.Mail.MailMessage()
    Dim myMailServer As System.Web.Mail.SmtpMail

    myMessage.To = Email
    myMessage.From = "[email protected]"
    myMessage.Subject = "You subject here"
    myMessage.Body = msgBody

    myMailServer.SmtpServer = "www.digitalims.net"
    myMailServer.Send(myMessage)

    myMessage = Nothing
    Return True
    End Function
    What do you mean ? What are you trying to do ?

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    11
    I'm trying to make a button that after the user has entered information it will take that info and send it in an e-mail, once i got this working I figured i could just manipulate the body text of the e-mail to include the info....

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2. EmailCust("[email protected]", "Hi , it's me .....")
    3. End Sub
    is this what you mean ?

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    11
    Thanks for the replys

    Getting that damn message again and it highlights almost the same exact thing

    myMailServer.Send(myMessage)

    I looked it up and the index says that the CDO is installed with outlook and i don't need to install it, maybe i do? maybe someone out there gets this error message?

    Any ideas?

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Does this help ??

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    11
    Yeah i think i know the problem now its the cdosys.dll file, the guy had a problem with it because it became un-registered, anyway how do you re-register a file? do i just reinstall it on my computer?

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    umm , is it one of OutLook Files ??

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    c:\WINDOWS\system32\regsvr32 cdosys.dll . this for XP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width