I had this button on a form which would generate a PDF of a report that would be saved in a specific location on my computer and then email a copy to a group of people. This works. I would like to now email a different form in PDF without saving it to my computer location and I am getting an error in the path. I tried using a Windows variable like %tmp% so it can be saved temporarily but access won't recognize this variable. Probably my code needs to be modified so i am attaching it below
The variables used in the code are already declared Public
Code:
Private Sub emailTest_Click()
On Error GoTo emailTest_Click_Err
flnm = "RMA " & RMAN & " TKT " & TicketN & ".pdf"
Sbj = "RMA# " & RMAN & " / TKT# " & TicketN
DoCmd.OutputTo acOutputReport, "RRMAPDF", acFormatPDF, flnm, , , , 0
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim MailAttachment As Outlook.Attachments
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
MailOutLook.Display
With MailOutLook
.subject = Sbj
.To = Me.Email
.CC = "support@domain.com"
.Attachments.Add flnm
.Display 'This will display the message for you to check and send yourself
' .Send ' This will send the message straight away
End With
emailTest_Click_Exit:
Exit Sub
emailTest_Click_Err:
MsgBox Error$
Resume emailTest_Click_Exit
End Sub