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.
Code:
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 = "Robert.patrician@va.gov"
varCC = "V21sfcconference@va.gov"
'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 V21SFCConference@va.gov. 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.