How to Quickly Forward an Email with Selected Attachments Only via Outlook VBA

When forwarding an Outlook email that has attachments, at times, you may want to only keep selected attachments instead of all. Now, in this article, we’ll teach you how to quickly forward a mail with selected attachments only.

In the standard way, when you forward an Outlook email, all original attachments will be forwarded. However, at times, you only wish to forward some attachments instead of all. Generally, you can forward the email as usual and then delete the unwanted attachments manually. But, it is a bit troublesome. Therefore, here we will introduce you a much quicker method to forward an email with only selected attachments.

Quickly Forward an Email with Selected Attachments Only

  1. At the very outset, launch Outlook VBA editor via “Alt + F11” shortcut.
  2. Then, copy and paste the following code into a project or module.
Sub ForwardMailWithSelectedAttachmentsOnly()
    Dim objMail As Outlook.MailItem
    Dim strTempFolder As String
    Dim strFile As String
    Dim objSelectedAttachments As Outlook.AttachmentSelection
    Dim objAttachment As Outlook.Attachment
    Dim objForward As Outlook.MailItem
 
    'Get the selected email
    Set objMail = Outlook.Application.ActiveExplorer.Selection.Item(1)
 
    'Get the selected attachments
    Set objSelectedAttachments = Outlook.Application.ActiveExplorer.AttachmentSelection
    If objSelectedAttachments.Count > 0 Then
       'Forward this email
       Set objForward = objMail.Forward
       objForward.Display
 
       'Delete all the forwarded attachments
       Do Until objForward.Attachments.Count = 0
          objForward.Attachments.Item(1).Delete
       Loop
 
       On Error Resume Next
       strTempFolder = "E:\Temp" & Format(Now, "yyymmddhhmmss") & "\"
       MkDir (strTempFolder)
 
       'Re-attach the selected attachments to the forward mail
       For Each objAttachment In objSelectedAttachments
           strFile = strTempFolder & objAttachment.FileName
           objAttachment.SaveAsFile (strFile)
           objForward.Attachments.Add (strFile)
       Next
 
       Kill strFile
    End If
End Sub

VBA Code - Quickly Forward an Email with Selected Attachments Only

  1. Next, exit the VBA editor.
  2. After that, follow the “Optional Step” in the previous post “How to Run VBA Code in Your Outlook” to add this macro to Quick Access Toolbar or ribbon.
  3. Eventually, you can try this macro.
  • First off, ensure that the reading pane is turned on.
  • Then, select an email and the attachments that you want to forward.
  • Next, click the macro button in Quick Access Toolbar or ribbon.Select Attachments and Run Macro
  • At once, a new email will display. As you can see, it is a forwarding email with only selected attachments.New Email with Only Selected Attachments

Fix Knotty Outlook Data Corruption

Have you ever come across Outlook crash? And have such crashes resulted in PST data corruption? If you have ever encountered such issues, you may have realized how knotty and troublesome they are. Usually, small problems can be solved with Inbox repair tool. But, for the serious troubles, like Outlook corruption, you have to utilize a more powerful utility, such as DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including SQL Server fix and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.