Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Could not access 'CDO.Message' when attaching file

Status
Not open for further replies.

magmo

Programmer
May 26, 2004
291
SE
Hi


I use this code to send a email, it works fine until I try to add an attachment, the I get the "Could not access 'CDO.Message' " error message. I cant see why this shouldn't work. Can anyone help?

Code:
Sub Mailstatistic(ByVal strFileName)
        Dim mail As New MailMessage
        mail.To = "name@domail.com"
        mail.From = "name@domail.com"
        mail.Subject = "this is a test email."
        mail.BodyFormat = MailFormat.Html
        mail.Body = "this is my test email body.<br><b>this part is in bold</b>"

        If System.IO.File.Exists("PDF_Files/" & strFileName) Then
            MsgBox("yes")
        Else
            MsgBox("no file")
        End If
        Dim attachment As New MailAttachment("PDF_Files/" & strFileName) 'create the attachment
        mail.Attachments.Add(attachment) 'add the attachment
        SmtpMail.SmtpServer = "xxx" 'your real server goes here        SmtpMail.Send(mail)
    End Sub


regards

 
Have you tried using a backslash and a full file name instead of the forward slash and a relative path?
 
Hi


When I added the full path ("c:\foldername\" & strFilename)

everything worked fine.


Thanks a lot!


Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top