Merge Emails with attachments with inbox rule to forward

Status
Not open for further replies.

Shawn Zeng

Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
Hi

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 -http://www.slipstick.com/developer/save-attachments-to-the-hard-drive/ (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.

Code:
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 =""
else
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.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Reply/Forward Emails using Mail Merge BCM (Business Contact Manager) 0
E After restore and merge outlook will not receive emails (Exchange) Using Outlook 4
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 New Slipstick.com Articles 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 New Slipstick.com Articles 0
Diane Poremsky Add attachments and set email fields during a mail merge to email New Slipstick.com Articles 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
J Contacts Notes field will not mail merge after migration to Exchange 2010 Exchange Server Administration 1
D Publisher 2010 (x64) not connecting with Outlook 2010 (x64) via Mail Merge Using Outlook 1
J Mail merge, labels, contact lists, address block Using Outlook 2
F Office 2010 Mail merge into Work 2010 using a specific Outlook catagory filter. Using Outlook 2
R cannot use public contact list for merge Using Outlook 1
F Attachments (such as pdf) in a mail merge Outlook 2010 Using Outlook 1
F Mail merge in Word/Outlook 2010 using multiple email accounts in Outlook Using Outlook 2
J mass email limitations when sending mails using mail merge. Using Outlook 2
S Merge Outlook mails to Windows Live Mail Inbox Using Outlook 4
H Mail Merge Contacts Using Outlook 4
G I have two address books, would like to merge Using Outlook 3
T User-defined fields in Outlook to be incorporated into Mail Merge documents Using Outlook 1
I E-mail Merge with Word/Outlook 2010 Exceptionally Slow Using Outlook 3
C Issues with ctearing mail merge file with Outlook 2010 & Win 7 Using Outlook 1
L In MS Office 2010 Contacts I need to merge two groups both called "company: None". Using Outlook 2
M Mail Merge email using data from MS Access Using Outlook 1
A Using Mailing Address in Mail Merge with BCM Using Outlook 1
V Outlook 2010 - attachments with mail merge email Using Outlook 4
1 MAIL MERGE NOT WORKING Using Outlook 5
G Problems Sending Publisher Mail Merge Newsletters Through Outlook. Using Outlook 1
A Merge accounts in 2010 Outlook Navigation Pane Using Outlook 2
L merge multiple email addresses to one pane Using Outlook 4
S mail merge and cc Using Outlook 2

Similar threads

Top