I have set up my database so that I can send an email with the click of a command button; however, I am unable to figure out how to attach a report to the email. I've tried several options (.attachment.add "rptTrainingRequests" along with others) and Ican send the email but there is no attachement. Here is the code I have written so far:
Private Sub cmdSend_Click()
Dim olApp As Object
Dim objMail As Object
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open'
If Err Then 'Outlook is not open'
End If
Set olApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook'
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.to = "EMail Address Here"
.Subject = "Training Request"
.HTMLBody = "Please see attached report and add employees to the training classes requested. Thank you."
.Attachments.Add "rptTrainingRequests"
.send
End With
MsgBox "Your request has been sent."
End Sub
Suggestions?