Can not access CDO.Message object

C

Carol

Hi,
I am using VB.NET2003 on a Windows XP. I tried to
write a simple program to send email with attachment (see
below for the code). I add reference to "Microsoft CDO
1.21 library" and "Microsoft CDO for Windows2000library".
It was compiled successfully. But I got run-time error
message "Can not access 'CDO.Message' object".
Did I miss something for XP here like PIA of CDO??
Thank you for your input!

Carol

Sub main()
Dim sTo As String, sFrom As String, sSubject As
String, sBody As String
Dim sAttach As String, sCc As String, sBcc As
String, sBodyEncoding As String
Dim sBodyFormat As String, sMailServer As String,
sPriority As String

Dim iLoop1 As Integer

sTo = "(e-mail address removed)"
sFrom = "(e-mail address removed)"
sSubject = "Test from Bachow"
sBody = "Test from MyCom"
sAttach = "R:\Load\Report\Latest_Signals.csv"
sCc = "(e-mail address removed)"
sBcc = "(e-mail address removed)"
sBodyFormat =
System.Text.Encoding.ASCII.EncodingName
sBodyEncoding = Web.Mail.MailFormat.Text
sPriority = Web.Mail.MailPriority.Normal

Dim MyMail As System.Web.Mail.MailMessage = New
System.Web.Mail.MailMessage

MyMail.From = sFrom
MyMail.To = sTo
MyMail.Subject = sSubject
MyMail.Body = sBody
MyMail.Cc = sCc
MyMail.Bcc = sBcc



' Build an IList of mail attachments.
If sAttach <> "" Then
Dim delim As Char = ","
Dim sSubstr As String
For Each sSubstr In sAttach.Split(delim)
Dim myAttachment As MailAttachment = New
MailAttachment(sSubstr)
MyMail.Attachments.Add(myAttachment)
Next
End If
Try
System.Web.Mail.SmtpMail.SmtpServer
= "Bachowimail.Bachow.com"
System.Web.Mail.SmtpMail.Send(MyMail)

Catch ex As Exception
Console.WriteLine("Can not send Email :" &
ex.Message)
End Try

End
 
M

Michel

Hi Carol,

CDO.Message is the object used when sending emails. I've had this error many
times and it was ALWAYS a problem connecting to the email server.
What you can try is change the email server (SmtpMail.SmtpServer). Also if
you don't, you can try to start the smtp server.

Hope this helps,
Michel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top