Private Sub test_Click()
On Error GoTo Err_test_Click
Dim stdocname, stdocname1, stdocname2, stdocname3, stdocname4, stdocname5, stdocname6, stdocname7 As String
Dim olapp As New Outlook.Application
Dim olnamespace As Outlook.NameSpace
Dim olmail As Outlook.MailItem
Set olnamespace = olapp.getnamespace("MAPI")
Set olmail = olapp.CreateItem(olmailitem)
stDocName = "ReportName1"
stDocName1 = "ReportName2"
stDocName2 = "ReportName3"
stDocName3 = "ReportName4"
stDocName4 = "c:\My Documents\1.doc"
stDocName5 = "c:\My Documents\2.doc"
stDocName6 = "c:\My Documents\3.doc"
stDocName7 = "c:\My Documents\4.doc"
DoCmd.OutputTo acOutputReport, stDocName, acFormatRTF, stdocname4
DoCmd.OutputTo acOutputReport, stDocName1, acFormatRTF, stdocname5
DoCmd.OutputTo acOutputReport, stDocName2, acFormatRTF, stdocname6
DoCmd.OutputTo acOutputReport, stDocName3, acFormatRTF, stdocname7
With olmail
.to = test@me.co.uk
.Body = "Please find reports"
.Subject = "Testing sending out more attachments"
.Attachments.add stdocname4
.Attachments.add stdocname5
.Attachments.add stdocname6
.Attachments.add stdocname7
.ReadReceiptRequested = False
.Send
End With
MsgBox vbCrLf & "Your Reports have been sent", _
vbInformation + vbOKOnly, "Reporting:"
Exit_test_Click:
Set olapp = Nothing
Set olmail = Nothing
Exit Sub
Err_test_Click:
Select Case Err
Case Else
strerrmsg = strerrmsg & "Error #: " & Format$(Err.Number) & vbCrLf & vbCrLf
strerrmsg = strerrmsg & "Error Description: " & Err.Description & vbCrLf
MsgBox strerrmsg, vbInformation, "test_click"
Resume Exit_test_Click
End Select
End Sub
This will use your outlook as opposed to Outlook express, however, it allows you to attach more than one file.
the docmd functions are outputting the reports (stdocname-3 that you have created in access), to locations stated in stdocname4-7. When the email is attaching the files, it will go to the right location it was outputted to. Therefore, you will be required to change the value of the stdocname4-7 to a more appropriate folder on the correct drives.
hope this helps?