• Email Attachment problem (2000(SP3))

    Author
    Topic
    #437079

    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 = “C:Documents 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.

    Viewing 0 reply threads
    Author
    Replies
    • #1038056

      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?

      • #1038077

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

    Viewing 0 reply threads
    Reply To: Email Attachment problem (2000(SP3))

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: