Error sending mail using smtp
-
This is the code i am using to try and send an email. I am using vb.net 2003
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click If txtto.Text = "" Then MsgBox("Please enter the address to send this message, E.g, Someone@someone.com") End If If txtto.Text <> "" Then Dim email As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage email.To = txtto.Text email.Cc = txtcc.Text email.Bcc = txtbcc.Text email.Subject = txtsubject.Text email.From = "someone@someone.com" email.Body = txtmessage.Text Dim sAttach As String = txtattach.Text If txtattach.Text <> "" Then Dim delim As Char = "," Dim sSubstr As String For Each sSubstr In sAttach.Split(delim) Dim myAttachment As MailAttachment = New MailAttachment(sSubstr) email.Attachments.Add(myAttachment) Next End If System.Web.Mail.SmtpMail.SmtpServer = "" System.Web.Mail.SmtpMail.Send(email)
Error hereEnd If End Sub
Error I get: An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object.My blog:[^]
-
This is the code i am using to try and send an email. I am using vb.net 2003
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click If txtto.Text = "" Then MsgBox("Please enter the address to send this message, E.g, Someone@someone.com") End If If txtto.Text <> "" Then Dim email As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage email.To = txtto.Text email.Cc = txtcc.Text email.Bcc = txtbcc.Text email.Subject = txtsubject.Text email.From = "someone@someone.com" email.Body = txtmessage.Text Dim sAttach As String = txtattach.Text If txtattach.Text <> "" Then Dim delim As Char = "," Dim sSubstr As String For Each sSubstr In sAttach.Split(delim) Dim myAttachment As MailAttachment = New MailAttachment(sSubstr) email.Attachments.Add(myAttachment) Next End If System.Web.Mail.SmtpMail.SmtpServer = "" System.Web.Mail.SmtpMail.Send(email)
Error hereEnd If End Sub
Error I get: An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object.My blog:[^]
There's lots of info out on the web about this. All you have to do is Google "tourbleshooting CDO.Message[^]".
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
This is the code i am using to try and send an email. I am using vb.net 2003
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click If txtto.Text = "" Then MsgBox("Please enter the address to send this message, E.g, Someone@someone.com") End If If txtto.Text <> "" Then Dim email As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage email.To = txtto.Text email.Cc = txtcc.Text email.Bcc = txtbcc.Text email.Subject = txtsubject.Text email.From = "someone@someone.com" email.Body = txtmessage.Text Dim sAttach As String = txtattach.Text If txtattach.Text <> "" Then Dim delim As Char = "," Dim sSubstr As String For Each sSubstr In sAttach.Split(delim) Dim myAttachment As MailAttachment = New MailAttachment(sSubstr) email.Attachments.Add(myAttachment) Next End If System.Web.Mail.SmtpMail.SmtpServer = "" System.Web.Mail.SmtpMail.Send(email)
Error hereEnd If End Sub
Error I get: An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object.My blog:[^]
Try this code. Hope this will help u. Public Function OpenEmail(ByVal EmailAddress As String) ', Optional ByVal Subject As String = "", Optional ByVal Body As String = "") As Boolean Dim bAns As Boolean = True Dim sParams As String sParams = EmailAddress If LCase(Strings.Left(sParams, 7)) <> "mailto:" Then sParams = "mailto:" & sParams 'If Subject <> "" Then sParams = sParams & _ ' "?subject=" & Subject 'If Body <> "" Then ' sParams = sParams & IIf(Subject = "", "?", "&") ' sParams = sParams & "body=" & Body 'End If Try System.Diagnostics.Process.Start(sParams) Catch bAns = False End Try Return bAns End Function
-
This is the code i am using to try and send an email. I am using vb.net 2003
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click If txtto.Text = "" Then MsgBox("Please enter the address to send this message, E.g, Someone@someone.com") End If If txtto.Text <> "" Then Dim email As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage email.To = txtto.Text email.Cc = txtcc.Text email.Bcc = txtbcc.Text email.Subject = txtsubject.Text email.From = "someone@someone.com" email.Body = txtmessage.Text Dim sAttach As String = txtattach.Text If txtattach.Text <> "" Then Dim delim As Char = "," Dim sSubstr As String For Each sSubstr In sAttach.Split(delim) Dim myAttachment As MailAttachment = New MailAttachment(sSubstr) email.Attachments.Add(myAttachment) Next End If System.Web.Mail.SmtpMail.SmtpServer = "" System.Web.Mail.SmtpMail.Send(email)
Error hereEnd If End Sub
Error I get: An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object.My blog:[^]
A***** wrote:
System.Web.Mail.SmtpMail.SmtpServer = ""
Sorry, I missed this line before. You MUST specify an SMTP server to use, either by IP address or by a valid DNS name. You cannot send mail without one.
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
This is the code i am using to try and send an email. I am using vb.net 2003
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click If txtto.Text = "" Then MsgBox("Please enter the address to send this message, E.g, Someone@someone.com") End If If txtto.Text <> "" Then Dim email As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage email.To = txtto.Text email.Cc = txtcc.Text email.Bcc = txtbcc.Text email.Subject = txtsubject.Text email.From = "someone@someone.com" email.Body = txtmessage.Text Dim sAttach As String = txtattach.Text If txtattach.Text <> "" Then Dim delim As Char = "," Dim sSubstr As String For Each sSubstr In sAttach.Split(delim) Dim myAttachment As MailAttachment = New MailAttachment(sSubstr) email.Attachments.Add(myAttachment) Next End If System.Web.Mail.SmtpMail.SmtpServer = "" System.Web.Mail.SmtpMail.Send(email)
Error hereEnd If End Sub
Error I get: An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll Additional information: Could not access 'CDO.Message' object.My blog:[^]