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
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
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
R Moved 6 months worth (approx 1500 emails) lost from moving from TPG inbox to Icloud inbox (folders) Using Outlook 3
U Approving Emails from iPhone Using Outlook 0
D cannot view emails in View pane (in the right pane), I only see one line or nothing Using Outlook 21
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
A Record opened emails for reopening later Using Outlook 2
Y Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
S Outlook 2016 Change how Outlook shows me contacts in emails Using Outlook 0
T Outlook creating unwanted tasks in Tasks and Todo from emails Using Outlook 1
Horsepower Moving emails between folder Outlook for Mac Outlook Wishlist 8
B Outlook 2016 Outlook crashes when trying to print certain emails Using Outlook 5
L IMAP Emails Disappear Using Outlook 0
L Need help modifying a VBA script for emails stuck in Outbox Outlook VBA and Custom Forms 6
S Macro to extract and modify links from emails Outlook VBA and Custom Forms 3

Similar threads

Top