I spent ages finding out how to add more than one attachment to an auto email, so thuoght i would just post the result here to add to the great knowledge base this forum is, hopefully to be of use to others in te future:
As obvious as it seems afterwards, simply duplicate the Set objOutlookAttach line: (This code based on Microsoft KB 318881)
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("jon@smith.com")
''Set objOutlookRecip = .Recipients.Add("fred@fake.net")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Steiger-Bowers")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Please ensure your records are up to date."
'Email body text
.Body = "Hello." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add("C:\MissingRecords.doc")
Set objOutlookAttach = .Attachments.Add("C:\MasterReport.doc")
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
As obvious as it seems afterwards, simply duplicate the Set objOutlookAttach line: (This code based on Microsoft KB 318881)
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("jon@smith.com")
''Set objOutlookRecip = .Recipients.Add("fred@fake.net")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Steiger-Bowers")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Please ensure your records are up to date."
'Email body text
.Body = "Hello." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add("C:\MissingRecords.doc")
Set objOutlookAttach = .Attachments.Add("C:\MasterReport.doc")
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send