I would really appreciate some help here...
I'm trying to use the SendEmails function below to automatically send email to users with multiple attachments.
When I call the function as such, it works fine as long as I have one attachment.
However, users need to send more than one attachment(max 3) sometime . The attachments are populated in the 3 fields on a form with the attachment path in them.
the first attachment field is mandatory, the other two, may or not be populated but they usually are.
After the user select the attachments, I need to call the SendEmails function and pass the attachments with the arrAttach arguments.
Any idea how this could be done ???. I tried different methods but was not successful.
the SendEmails function is below. It's declared as a Module.
I'm trying to use the SendEmails function below to automatically send email to users with multiple attachments.
When I call the function as such, it works fine as long as I have one attachment.
Code:
SendEmails(strTo, strSubject, strMessage, arrAttach)
the first attachment field is mandatory, the other two, may or not be populated but they usually are.
After the user select the attachments, I need to call the SendEmails function and pass the attachments with the arrAttach arguments.
Any idea how this could be done ???. I tried different methods but was not successful.
the SendEmails function is below. It's declared as a Module.
Code:
Public Function SendEmails(strTo As String, _
strSubject As String, _
strMessage As String, _
strAttachment As String)
On Error GoTo ErrHandle_Err
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
'Set the variables
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
objOutlookMsg.To = strTo
objOutlookMsg.Subject = strSubject
objOutlookMsg.HTMLBody = strMessage
objOutlookMsg.BodyFormat = olFormatHTML
objOutlookMsg.Importance = olImportanceHigh
objOutlookMsg.Attachments.Add strAttachment, olByRef, 1, "Document"
objOutlookMsg.Send
End With
Set objOutlook = Nothing
ErrHandle_Exit:
Exit Function
ErrHandle_Err:
Exit Function
End Function