Merge Emails with attachments with inbox rule to forward

Not open for further replies.

Shawn Zeng

Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server

Please help. I have a requirement to create an inbox rule that will merge two emails each with attachment into one email with the attachments from both mail and with dynamic date subject line. See below

1. Received daily at 8 am email subject A with PDF attachment
2. Recieved daily at 8 am email subject B with Excel attachment

Desired outcome

Consolidate both attachments into one mail and forward out, for example
To: Dis
Subject: Consolidated A & B
Attachment: Both PDF and Excel
Body: Consolidated reports

Please let me know if there is a way to accomplish this, thanks in advance!

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
A run a script rules should be able to do it - i would use a script to save the attachments to a folder then a second script to create the consolidated email message. I have links to sample scripts at the bottom of this page - Outlook's Rules and Alerts: Run a Script

I'd tweak this to apply only to the two messages - (run a script is at the bottom) - this would be the easy part. I tend to prefer itemadd macros but using a rule allows you to set conditions so it doesn't run on other messages. If the attachment names are always the same or use a specific format, we can check for the name - then it won't matter if itemadd gets other attachments.

The hard part is making sure both attachments arrive before creating the consolidated message. Hmmm. Have the same macro set a variable on the first message and if it has a value, send the message. The variable would be wiped out when outlook restarts, but as long as both arrive at about the same time, that shouldn't be a problem.

(changed the save attachments link to a better one :))

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
this might have some bugs in it because i didn't have time to test it - but you can see if it works to save the attachments. after the second one is saved, a message box will come up (so you can test it on any pdf or xlsx file)- that would be replaced by the code to send them out.

Public Sub SaveAttachments(Item As Outlook.MailItem)

If Item.Attachments.Count > 0 Then
Dim objAttachments As Outlook.Attachments
Dim lngCount As Long
Dim strFile As String
Dim sFileType As String
Dim i As Long
dim strHaveOne as string

' Get the path to your My Documents folder
    strfolderpath = CreateObject("WScript.Shell").SpecialFolders(16)
    strfolderpath = strfolderpath & "\Attachments\"

Set objAttachments = Item.Attachments
    lngCount = objAttachments.Count
For i = lngCount To 1 Step -1
    ' Get the file name.
    strFile = objAttachments.Item(i).filename
' This code looks at the last 4 characters in a filename
      sFileType = LCase$(Right$(strFile, 4))
      Select Case sFileType
' Add additional file types below
       Case ".pdf", "xlsx"
      End Select

if sFileType = 1 then
strFile = objAttachments.Item(i).FileName

' Combine with the path to the folder.
strFile = strfolderpath & strFile

' Save the attachment as a file.
    objAttachments.Item(i).SaveAsFile strFile

end if   

    Next i

End If

if strHaveOne = "Recieved" then
'run the send macro
msgbox "have both attachments"
strHaveOne =""
strHaveOne = "Recieved"
end if

End Sub

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Redirect is only available for Exchange accounts. i don't think its available in rules - but as long as you have send as permission on the account, you can use vba to send as that address.
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
R Outlook 2021 Having problem setting up outlook 2021 with windows 11. I have 3 gmail accounts and I want the 3 gmail, emails to merge into the same outlook input. Using accounts in Outlook 0
A Reply/Forward Emails using Mail Merge BCM (Business Contact Manager) 0
Cathy Rhone Mail merge error message Using Outlook 2
glnz How set up new IMAP on Outlook-Office 365 and merge in pst from Outlook 2003 for same two email accounts? Using Outlook 5
L Merge two contacts folders Using Outlook 1
Randy Redekopp How To Merge Contact Info to Email Custom Form Template Using Outlook 2
K Delay Send and Mail Merge Outlook VBA and Custom Forms 4
M Mail merge to single contacts + contact groups? Using Outlook 4
O Merge .pst files (without structure) Using Outlook 7
Diane Poremsky Add Attachments and Set Email Fields During a Mail Merge Using Outlook 0
C Merge two archive calendars Using Outlook 1
iwshim outlook mail merge -rich text Using Outlook 2
Diane Poremsky Create a list of color categories and merge or restore the list using VBA Using Outlook 0
Diane Poremsky Add attachments and set email fields during a mail merge to email Using Outlook 0
H Mail Merge status remaining "Not Executed" BCM (Business Contact Manager) 1
iwshim mail merge and add the contact picture outlook 2013 Using Outlook 3
S Custom field not populating in Custom View or Mail Merge Exchange Server Administration 2
W Combine Mail Merge to Distribution List with Auto Attachments - Outlook 2007 Using Outlook 1
B Two Inboxes after upgrade, how to merge? Using Outlook 4
A Two outlook calendars - how do I merge them Using Outlook 3
M Using mail merge with stationery Using Outlook 5
B MS Office 2010: Word email merge not selecting default Outlook account Using Outlook 1
P Mail Merge vs Direct Mail Print BCM (Business Contact Manager) 4
A Mail Merge - Sent but still in Outbox Using Outlook 5
R specify from account in mail merge Using Outlook 3
G Mail Merge via Proxy Email? Using Outlook 2
B Need to merge PST, and remove duplicate items Using Outlook 3
A Outlook 2007 Mail Merge not working anymore Using Outlook 1
S mail merge and cc Using Outlook 2
A E-Mail Merge to All E-Mail Addresses on One BCM Contact BCM (Business Contact Manager) 1
R My email merge/business contact manager fields are not populating BCM (Business Contact Manager) 1
G VBA Interfering with Email Addresses in Mail Merge? Outlook VBA and Custom Forms 2
B How-to Mail Merge with an attachment? BCM (Business Contact Manager) 2
K Mail Merge to email with attachments Outlook VBA and Custom Forms 8
B Marketing Campaign BCM 2007 – Word 2007 Merge Fails BCM (Business Contact Manager) 1
R How Do I Merge Several PST Files? Using Outlook 4
H Outlook - Mail Merge Outlook VBA and Custom Forms 1
F Color code certain INBOX emails Using Outlook 2
J gmail and deleted emails. Using Outlook 0
Z Outlook 2021 Outlook new emails notification not working Using Outlook 5
J Outlook 365 Outlook Macro to Sort emails by column "Received" to view the latest email received Outlook VBA and Custom Forms 0
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
U Outlook not responding when trying to print Emails Using Outlook 6
K mark emails with colour manually (like in thunderbird) Using Outlook 1
richardwing Outlook 365 VBA to access "Other Actions" menu for incoming emails in outlook Outlook VBA and Custom Forms 0
U Outlook on the iPhone cannot approve filtered Emails Using Outlook 0
K Outlook 365 After migrating to Outlook 365, some contacts display in emails with prefixes Using Outlook 0
B Move emails from one account to another Outlook VBA and Custom Forms 2
D Unable to view older emails in desktop app Using Outlook 0
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1

Similar threads