Public Function Outlook_SendEmail(ByVal strTo As String, _ ByVal strSubject As String, _ ByVal strMsg As String, _ EditMail As Boolean, _ ParamArray AttachmentList() As Variant) As Boolean 'Purpose : Automatically send email via late-binding Outlook Automation. ' Will use Redemption DLL if registered on sending machine. ' ' Call like this: ' Call Outlook_SendEmail("Bill.Mosca@MyDomain.com", "Hey there.", _ "Here is my message", True, "C:\MyFiles\Test1.txt", "C:\MyFiles\Test2.txt") 'DateTime : 7/28/2008 14:14 'Author : Bill Mosca, modified by ChrisO to use Array for attachments. Dim objOLApp As Object 'Outlook.Application Dim outItem As Object 'MailItem Dim outFolder As Object 'MAPIFolder Dim outNameSpace As Object 'NameSpace Dim lngAttachment As Long On Error GoTo err_Outlook_SendEmail Set objOLApp = CreateObject("Outlook.Application") Set outNameSpace = objOLApp.GetNamespace("MAPI") Set outFolder = outNameSpace.GetDefaultFolder(6) 'olFolderInbox=6 Set outItem = objOLApp.CreateItem(0) 'olMailItem=0 outItem.Body = strMsg outItem.Subject = strSubject outItem.To = strTo With outItem.Attachments For lngAttachment = LBound(AttachmentList) To UBound(AttachmentList) .Add AttachmentList(lngAttachment) Next lngAttachment End With 'Send using Redemption late-binding. Dim SafeItem As Object Set SafeItem = CreateObject("Redemption.SafeMailItem") With SafeItem .Item = outItem .To = strTo .Subject = strSubject .HTMLBody = strMsg With .Attachments For lngAttachment = LBound(AttachmentList) To UBound(AttachmentList) .Add AttachmentList(lngAttachment) Next lngAttachment End With If EditMail Then .Display (True) Else: .Send End If End With finish: Outlook_SendEmail = True exit_Outlook_SendEmail: On Error Resume Next Set outItem = Nothing Set outFolder = Nothing Set outNameSpace = Nothing Set objOLApp = Nothing Exit Function err_Outlook_SendEmail: Select Case Err.Number Case 287 'User stopped Outlook from sending email. MsgBox "Email Cancelled.", vbInformation, "DCDS" Case 429 'Redemption DLL not registered on this machine. Use Outllok object. If EditMail Then outItem.Display (True) Else: outItem.Send End If Case Else MsgBox "Error " & Err.Number & " (" & Err.Description _ & ") in procedure Outlook_SendEmail of Module mod_Utilities" End Select Resume exit_Outlook_SendEmail End Function