PC Review


Reply
Thread Tools Rate Thread

Can not access CDO.Message object

 
 
Carol
Guest
Posts: n/a
 
      23rd Dec 2003
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 Removed)"
sFrom = "(E-Mail Removed)"
sSubject = "Test from Bachow"
sBody = "Test from MyCom"
sAttach = "R:\Load\Report\Latest_Signals.csv"
sCc = "(E-Mail Removed)"
sBcc = "(E-Mail 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

 
Reply With Quote
 
 
 
 
Michel
Guest
Posts: n/a
 
      24th Dec 2003
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

"Carol" <(E-Mail Removed)> wrote in message
news:196701c3c977$9d583240$(E-Mail Removed)...
> 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 Removed)"
> sFrom = "(E-Mail Removed)"
> sSubject = "Test from Bachow"
> sBody = "Test from MyCom"
> sAttach = "R:\Load\Report\Latest_Signals.csv"
> sCc = "(E-Mail Removed)"
> sBcc = "(E-Mail 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
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not access CDO.Message object Rotsey Microsoft Dot NET 0 18th Mar 2008 12:34 PM
Could not access CDO.Message object Rotsey Microsoft C# .NET 0 18th Mar 2008 10:50 AM
Could not access 'CDO.Message' object. Thomas I. Microsoft ASP .NET 2 10th Apr 2005 10:13 PM
Could not access 'CDO.Message' object Scott Faso via .NET 247 Microsoft Dot NET 0 16th Jun 2004 02:50 PM
Could not access CDO.message object Abc Microsoft ASP .NET 1 29th Dec 2003 06:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:09 AM.