By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,402 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,402 IT Pros & Developers. It's quick & easy.

The specified protocol is unknown. Error while trying to send email with attachment.

P: n/a
Errors:
An unhandled exception of type 'System.Web.HttpException' occurred in
system.web.dll

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

innerexception is "Exception has been thrown by the target of an
invocation."

innerexception.innerexception is "The specified protocol is unknown."

I experimented, removing the attachment references and the error goes
away, the email is sent, and recieved. My code for sending the mail
with attachment looks like this:

Dim attachment As New System.web.mail.MailAttachment(filename)
Dim Message As New System.Web.Mail.MailMessage
Message.To = " <m_*********@yahoo.com>"
Message.From = "Order System <m_*********@yahoo.com>"
Message.Body = "Attachment: text file"
Message.Subject = "Your Request"
Message.Attachments.Add(attachment)
System.Web.Mail.SmtpMail.SmtpServer = "mail.company.local"
System.Web.Mail.SmtpMail.Send(Message)

I'm beginning to suspect that the problem may stem from this actually
being a windows application instead of a web application. I imported
System.Web references which includes System.Web.Mail of course. Is
there something else I need in references?

Let me know if more code is needed to troubleshoot. Thank you.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* m_*********@yahoo.com (m_evergreen) scripsit:
An unhandled exception of type 'System.Web.HttpException' occurred in
system.web.dll

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


Did you already have a look here?

<URL:http://www.systemwebmail.net/>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2

P: n/a
Thank you, I've found a fix for the problem. I started by adding c:/ to
my file name, giving me something like this:

filename = "c:/" & tbl.Rows(A)("CustomerID") & tbl.Rows(A)("FilterID") &
".txt"

This worked on my machine but I was concerned that it might not work on
the server. After giving it some thought I changed the code again
adding to the top:

Imports System.io

and then later in the code:

direct = Directory.GetCurrentDirectory()
filename = direct & tbl.Rows(A)("CustomerID") & tbl.Rows(A)("FilterID")
& ".txt"

I hope this will help anyone in a similar situation.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.