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