Results 1 to 2 of 2
  1. #1
    securitywyrm is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013

    Attach file to email? .attachments.add results in error

    I'm trying to attach a particular form to a file I have to send on a regular basis. However all the guides say to use .attachments.add , which isn't working. For simplicity, the file to attach is Y:\Education\Databases\test.txt

    The current error is "Compile error: Invalid or Unqualified reference." with ".attachments" highlighted.

    Private Sub EMAILTEST_Click()
     Dim varName As Variant
    Dim varCC As Variant
    Dim varSubject As Variant
    Dim varBody As Variant
    Dim ClaimFormPath As Variant
    ClaimFormPath = "Y:\Education\Databases\test.txt"
    ' Location for file to attach
    varName = ""
    varCC = ""
    'separate each email by a ','
    varSubject = Me.Event
    'Email subject
    varBody = "Congratulations " & Me.Identification & "." & vbCrLf & "Your registration reimbursement for " & Me.Event & " on " & Me.DateStart & " has been approved! This email contains instructions on how to be reimbursed." & vbCrLf & "Attached is form 1164, Claim for reimbursement for expenditures on official business. This form should be submitted within five business days after the end of the event to Your Purchase Order number is " & Me.PO & ", place the purchase order number in field #5. Your supervisor is to sign block #8, you are to sign block #10. Reimbursement is done through a direct deposit to your bank account. There will be no email notification of this direct deposit. Please allow 4 weeks from submission of completed reimbursement packet for payment."
    'Body of the email
    .attachments.Add ClaimFormPath
    'add attachment. This is where it's broken
    DoCmd.SendObject , , , varName, varCC, , varSubject, varBody, True, False
    'Send email command. The True after "varBody" allows user to edit email before sending.
    'The False at the end will not send it as a Template File
    End Sub
    Any help would be much appreciated. If I can get this working, I have a much larger project with hundreds of reports I could deploy it on.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    The Great Land
    AFAIK, can't use SendObject for email attaching external file. Common topic. Review
    How to attach file: To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 28
    Last Post: 07-05-2017, 01:34 AM
  2. Replies: 5
    Last Post: 04-27-2015, 12:26 PM
  3. Replies: 5
    Last Post: 09-05-2014, 12:06 PM
  4. Attach Database to Email
    By SSgtBarry in forum Access
    Replies: 2
    Last Post: 08-10-2014, 08:42 PM
  5. Can't attach to email
    By newtoAccess in forum Access
    Replies: 10
    Last Post: 12-03-2010, 02:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Other Forums: Microsoft Office Forums - Senior Forums