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
An unhandled exception of type 'System.Web.HttpException' occurred in

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

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

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_*********>"
Message.From = "Order System <m_*********>"
Message.Body = "Attachment: text file"
Message.Subject = "Your Request"
System.Web.Mail.SmtpMail.SmtpServer = ""

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_********* (m_evergreen) scripsit:
An unhandled exception of type 'System.Web.HttpException' occurred in

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

Did you already have a look here?


Herfried K. Wagner [MVP]
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") &

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:


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 ***
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.