-
Hi all! I’m new to the group; I had a friend in my computer science class tell me about the group. So my problem is this. I’m building a program for a charity group what they want it to do is take a picture of someone via webcam and then email it to anyone the use specifies a lot like the one at the Microsoft Museum If anyone has been there. So it has turned into my class project. I have ran into a problem with the sending of the email. The program won’t be using a local SMTP server it will be using one like Comcast (smtp.comcast.net) when I run the program everything is fine until it runs the last line of code and then I get this error message. An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object. I was wondering if anyone could help me with it? I have tried declaring the SMTP server in different areas but nothing seems to work Thanks for any help
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim **objEmailMessage** As System.Web.Mail.MailMessage Dim objSMTPServer As System.Web.Mail.SmtpMail objSMTPServer.SmtpServer = "smtp.comcast.net" objEmailMessage = New System.Web.Mail.MailMessage With objEmailMessage .To = "crazyboutcomputers1@comcast.net" .From = txtFrom.Text .Subject = "Great Job!" .Body = "Want all my money?" End With **objSMTPServer.Send(objEmailMessage)** End Sub
The code in red at the bottom is what im have truble with and when i click go to definition it gos to the one in green at the top. Agen Thanks for any Help -
Hi all! I’m new to the group; I had a friend in my computer science class tell me about the group. So my problem is this. I’m building a program for a charity group what they want it to do is take a picture of someone via webcam and then email it to anyone the use specifies a lot like the one at the Microsoft Museum If anyone has been there. So it has turned into my class project. I have ran into a problem with the sending of the email. The program won’t be using a local SMTP server it will be using one like Comcast (smtp.comcast.net) when I run the program everything is fine until it runs the last line of code and then I get this error message. An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object. I was wondering if anyone could help me with it? I have tried declaring the SMTP server in different areas but nothing seems to work Thanks for any help
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim **objEmailMessage** As System.Web.Mail.MailMessage Dim objSMTPServer As System.Web.Mail.SmtpMail objSMTPServer.SmtpServer = "smtp.comcast.net" objEmailMessage = New System.Web.Mail.MailMessage With objEmailMessage .To = "crazyboutcomputers1@comcast.net" .From = txtFrom.Text .Subject = "Great Job!" .Body = "Want all my money?" End With **objSMTPServer.Send(objEmailMessage)** End Sub
The code in red at the bottom is what im have truble with and when i click go to definition it gos to the one in green at the top. Agen Thanks for any HelpYour problem is that you instantiated an SmtpMail object. You don't have to. SmtpMail is one of those objects that you just use, kind of like a service that's been declared already. Just a little tweak of your code results in this:
Dim objEmailMessage As System.Web.Mail.MailMessage objEmailMessage = New System.Web.Mail.MailMessage With objEmailMessage .To = "crazyboutcomputers1@comcast.net" .From = txtFrom.Text .Subject = "Great Job!" .Body = "Want all my money?" End With SmtpMail.SmtpServer = "smtp.comcast.net" SmtpMail.Send(objEmailMessage)
This should work for you. Oh! Don't forget the reference to System.Web! RageInTheMachine9532
-
Your problem is that you instantiated an SmtpMail object. You don't have to. SmtpMail is one of those objects that you just use, kind of like a service that's been declared already. Just a little tweak of your code results in this:
Dim objEmailMessage As System.Web.Mail.MailMessage objEmailMessage = New System.Web.Mail.MailMessage With objEmailMessage .To = "crazyboutcomputers1@comcast.net" .From = txtFrom.Text .Subject = "Great Job!" .Body = "Want all my money?" End With SmtpMail.SmtpServer = "smtp.comcast.net" SmtpMail.Send(objEmailMessage)
This should work for you. Oh! Don't forget the reference to System.Web! RageInTheMachine9532
the error I'm geting now is ( name smtpmail not decalrad ) Its refuring to the last 2 lines of code.
-
the error I'm geting now is ( name smtpmail not decalrad ) Its refuring to the last 2 lines of code.
Do you have this at the top of your code? I assumed you did already, based on your example. My mistake! :doh:
Imports System.Web.Mail
RageInTheMachine9532
Visual Basic
4
Posts
2
Posters
0
Views
1
Watching