Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email Attachment problem (2000(SP3))

    I'm trying to Automate sending some reports from Access. I have all of the Outlook side of things working fine except for the attachment itself
    The current version uses the following with respect to the attachment itself:
    Dim attachmentPath as Variant (It didn't like strings either)
    AttachmentPath = "Cocuments and SettingsPeter NikiforukDesktopCCGGrptArtistStatement.pdf"
    Set objOutlookAttach = .Attachments.Add(AttachmentPath)

    I have recieved a number of errors depending on whether I specify a type in the attachments.add. With no type specificed I'm getting error 13 Type mismatch. No matter what I try, Outlook doesn't like any path. I even tried putting a document in the root directory (e.g. "C:xyz.txt") and outlook still couldn't find the document to attach.

    This is currently running as a sub in the on click event of a button.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Email Attachment problem (2000(SP3))

    I suspect the problem lies in some code you have not shown us.
    Here is some code cut and pasted from a working app


    Dim Outlk As Outlook.Application
    Dim oMailItem As Outlook.MailItem
    Dim oAttachment As Object
    Set Outlk = New Outlook.Application
    .....etc

    Dim sAttachment As String
    Set oMailItem = Outlk.CreateItem(olMailItem)
    Set oAttachment = oMailItem.Attachments.Add(sAttachment)

    ___________

    In this line you have . operator
    Set objOutlookAttach = .Attachments.Add(AttachmentPath)

    This assumes you are within a 'with' operator. Is there one? Is it the right one?
    Regards
    John



  3. #3
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email Attachment problem (2000(SP3))

    I woke up at 6:30 this morning (after going to bed at 1, ungodly hours both) with the same thought, but your post clarified it and sure enough, I had grabbed some code that Hans put together, but obviously for a slightly different task and he had a reference to the attachments collection and I needed a reference to an attachment object.

    dim objAttachment as Outlook.Attachment

    with no "s" solved the problem. Argh! 2hours for being monumentally stupid! <img src=/S/bash.gif border=0 alt=bash width=35 height=39>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •