Hi,
I used the following code within a module. This was necessary, because sending this email is only one part of a process and I set all steps into a macro and create a command button to run the full process at once (new requirement).
Before this requirement came up, I send the email through a command button. There I was able to enter a distribution list in the code. But this changed and I can't use it any more.
Function SendEmail()
Dim OL As Object
Dim MailSendItem As Object
On Error GoTo Err_SendEmail
'Create an instance of Outlook
Set OL = CreateObject("Outlook.Application")
'Create a new mail Item
Set MailSendItem = OL.CreateItem(olMailItem)
With MailSendItem
.Subject = "Report"
.To =
"email@email.com"
.body = "The attached..."
.Attachments.Add "C:\Temp\report.xls"
.NoAging = False 'Ensures a response is returned to you if not opened
.Send
Set OL = Nothing
End With
Exit_SendEmail:
Err.Clear
On Error Resume Next
Exit Function
Err_SendEmail:
MsgBox "Error while executing SendEmail routine. " & Err.Description, vbCritical
Resume Exit_SendEmail:
End Function
Does this help?
Hi,
How have you managed to activate Outlook from Access...
I've always used docmd.sendobject
:)