Needing help with reply/reply all while keeping attachments and adding a new CC recipient.

Status
Not open for further replies.

broadbander

Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
I was wanting to see if there is a way to Reply to the sender of an e-mail in Outlook 2013 while attaching all the attachments that the sender sent while adding a carbon copy of a new recipient?

I know the following code can either Reply or Reply All, but I am having an issue trying to figure out the carbon copy, I don't have an issue with the Outlook security window showing up. I've tried using other vba examples to CC an address, but they all fail and I am suspecting perhaps it has to do with the first part below of "Set rpl = itm.ReplyAll".

Any ideas on how I can use reply/all to send attachments, keeping the e-mail chain complete and add a new recipient to the CC box?

Sub ReplyWithAttachments()
Dim rpl As Outlook.MailItem
Dim itm As Object

Set itm = GetCurrentItem()
If Not itm Is Nothing Then
Set rpl = itm.ReplyAll
CopyAttachments itm, rpl
rpl.Display
End If

Set rpl = Nothing
Set itm = Nothing
End Sub

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select

Set objApp = Nothing
End Function

Sub CopyAttachments(objSourceItem, objTargetItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
Next

Set fldTemp = Nothing
Set fso = Nothing
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This is creating the message:
Set rpl = itm.ReplyAll
CopyAttachments itm, rpl
rpl.Display

since there are no addresses in the BCC field, you can use this (it erases the values already there):
rpl.bcc = "alias@domain.com"

The other way is using the recipients collection. You'd have to use this method to add to existing addresses, as it adds, not replaces (but it works to add the only address too):
Dim objRecip As Recipient
Set objRecip = rpl.Recipients.Add("alias@domain.com")
objRecip.Type = olBCC

in either case it goes before .display
 

broadbander

Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Thank you for the response!

Oddly if I use the below with added code, the macro doesn't execute at all. if I remove the three lines of code, it executes with the reply and attachments being added. If I try with just rpl.BCC = "alias@domain.com", the macro won't process until I remove it. Am I entering it wrong?


Sub ReplyWithAttachments()
Dim objRecip As Recipient
Dim rpl As Outlook.MailItem
Dim itm As Object

Set objRecip = rpl.Recipients.Add("user@domain.com")
objRecip.Type = olBCC

Set itm = GetCurrentItem()
If Not itm Is Nothing Then
Set rpl = itm.ReplyAll
CopyAttachments itm, rpl
rpl.Display
End If

Set rpl = Nothing
Set itm = Nothing
End Sub

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select

Set objApp = Nothing
End Function

Sub CopyAttachments(objSourceItem, objTargetItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
Next

Set fldTemp = Nothing
Set fso = Nothing
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
it took me a while to see the error - you need the dim at the top (ok) and the other stuff after you set the reply object, not before.
put this right before .display:
Set objRecip = rpl.Recipients.Add("user@domain.com")
objRecip.Type = olBCC
rpl.Display
End If
 

broadbander

Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Well.. nevermind.. it looks like rpl.BCC = "alias@domain.com" started working on its own... as did the second way! Thank you for all the help! Perfect!
 

broadbander

Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
it took me a while to see the error - you need the dim at the top (ok) and the other stuff after you set the reply object, not before.
put this right before .display:
Set objRecip = rpl.Recipients.Add("user@domain.com")
objRecip.Type = olBCC
rpl.Display
End If
Thank you for that! I was playing with it likely alongside you without realizing it! Thank you very much Diane!
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
R New chap saying hello and needing advice on Outlook 2007 thumbnails Using Outlook 3
V pst repeatedly needing repair Using Outlook 2
J email Folders, needing to have main folders turn bold when subfolders receive mail. Using Outlook 1
O Send and Receive Error Password Keeps needing to be reloaded Using Outlook 1
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
O Help .. got lost ... installing Office like 2016 Using Outlook 5
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
I Help with dates in task list. Using Outlook 5
C need help setting up outlook first time Using Outlook 1
K To do bar help Using Outlook 8
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
S help with outlook scripting Outlook VBA and Custom Forms 4
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
EmelineGueguen Help to understand the problem of work Using Outlook 1
N Outlook Forms Help Outlook VBA and Custom Forms 2
N Need help syncing contacts to iPhone X Using Outlook 8
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
J Help! My contacts have disappeared. Using Outlook 5
J HELP- Rule to auto strip prepend from external emails Using Outlook 0
J Help Needed With Multi-Step Login Email Address Using Outlook.com accounts in Outlook 1
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
G [Help] Converting array to destination folder path Outlook VBA and Custom Forms 1
K Help.... Office Outlook 2016 Using Outlook 1
S Error using AddressEntry.GetContact - need help Outlook VBA and Custom Forms 2
D Help with code to move mail on receipt to another folder based on time received Outlook VBA and Custom Forms 2
EaglePI Outlook 2010 need help with rules Using Outlook 0
B HELP! Using Outlook 4
Jeff Davis Help fix my Outlook 2013? Using Outlook 28
M Winmail. dat - HELP Using Outlook 2
Diane Poremsky Help! My Contacts are being updated! New Slipstick.com Articles 0
B VBA Help Email that will save as draft and send as attachment Outlook VBA and Custom Forms 3
J Can Anyone Help?? Outlook VBA and Custom Forms 1
C Newbie needs help with Outlook Macro Outlook VBA and Custom Forms 3
B Need Help - Willing to pay Outlook VBA and Custom Forms 10
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
G Looking for help with our Organization Forms Library Outlook VBA and Custom Forms 1
J Need Help with Contacts VBA Outlook VBA and Custom Forms 1
L Outlook 2002: HTML Emails Will Not Print: Please Help Using Outlook 0
H Need help setting up GetFolderPath-Makro with Vodafone IMAP Mail-Account Outlook VBA and Custom Forms 0
A newb outlook macro help Outlook VBA and Custom Forms 1
T Need help with finding/updating task Outlook VBA and Custom Forms 1
X Help with custom form which is very similar to Tasks Outlook VBA and Custom Forms 6
joflo copy contents from outlook to excell - please help. Using Outlook 4
P Outlook 2010: Missing tab - "Format/Picture Tools" HELP! Using Outlook 3
L Looking for help - want to try an alternative to Outlook? Outlook Wishlist 0
M Help! Can't set up IMAP for gmail Using Outlook 2
Similar threads


















































Top