Forwarding email based on the attachment file type and specific text found on the attachment file name

Status
Not open for further replies.

dreams

New Member
Outlook version
Outlook 2016 64 bit
Email Account
POP3
Hi,

I am not very familiar with VBA codes. Normally I would get several type of files (refer below attached image) in the email attachments.

I wanted to forward that same email with the attachment file extension having ".RDD" and all the PDF attachments except the PDF file name having a text "Transmittal" in it.

Can you someone help me on this?

.
Screenshot.jpg
 
Hi

I could able to find out the following code from a website which only filtering PDF files. Can someone help me to re-write the below code to include ".RDD" file and the PDF file name doesn't contain the text "Transmittal"? it will be great help. Thank you.

Code:
Sub ForwardEmailwithPDFAttachmentsOnly()

        ' Send Completed Message to Accenture

        On Error Resume Next

        Dim oApp As Outlook.Application
        Dim objFolder As Outlook.MAPIFolder
        Set oApp = New Outlook.Application
        Set objNS = Application.GetNamespace("MAPI")
        Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
        Dim oEmail As Outlook.MailItem
        Dim strFile As String
        Dim sFileType As String
        Dim bk, fg As Integer

        'Require that this procedure be called only when a message is selected
        If Application.ActiveExplorer.Selection.Count = 0 Then
            Exit Sub
        End If

        For Each objItem In Application.ActiveExplorer.Selection
            If objFolder.DefaultItemType = olMailItem Then
                If objItem.Class = olMail Then
                    Response = MsgBox("Forward message (" + Item.Subject + ") to Appended Subject")

                    Set myforward = objItem.Forward
                    myforward.Display

                    bk = myforward.Attachments.Count
                    fg = 1
                    For i = 1 To bk
                        If InStr(LCase(myforward.Attachments(fg).FileName), ".pdf") = 0 Then
                            myforward.Attachments(fg).Delete
                            Else: fg = fg + 1
                        End If
                    Next i

                    End If
            End If
        Next

        End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Outlook 2019 Help with forwarding email without mentioning the previous email sender. Outlook VBA and Custom Forms 0
T Original email text not shown when replying or forwarding the email. Using Outlook 9
D Keep Original html body when forwarding an email Outlook VBA and Custom Forms 7
I Forwarding attachments in email received Outlook VBA and Custom Forms 3
A Forwarding email and replacing body Outlook VBA and Custom Forms 1
D VBA to edit body of incoming email and forwarding it Outlook VBA and Custom Forms 11
G VBA/Macro to remove page colour when replying or forwarding email Outlook VBA and Custom Forms 2
N Auto-forwarding an Email received from a specific Email address After slight modifications Using Outlook 4
D Forwarding Exchange Email without meeting updates Using Outlook 1
P Forwarding Email With Encrypted Attachment Exchange Server Administration 1
V Re: Email Forwarding Outlook VBA and Custom Forms 1
F Outlook 2019 Forwarding Message and Keeping Unread Status Outlook VBA and Custom Forms 0
A Automatic forwarding to different people on a rotational basis Using Outlook 2
R Auto Forwarding with different "From" Outlook VBA and Custom Forms 0
P Forwarding emails issue with special characters replacing text body Using Outlook 1
S Customize the autocolor font choices for replying/forwarding messages Outlook VBA and Custom Forms 2
R Retain Original Message When Forwarding With Macro Outlook VBA and Custom Forms 3
M VBA Rule for removing all body but hyperlink then forwarding Outlook VBA and Custom Forms 9
W Forwarding E-Mail Outlook VBA and Custom Forms 13
D VBA Code to strip Subject Line when replying or forwarding Using Outlook 3
R Forwarding and keeping Original intact Using Outlook 3
J Creating a URL from a message body excerpt before forwarding Using Outlook 2
J Outlook Rule - Create Link in Forwarding Message Outlook VBA and Custom Forms 2
E Contact's Notes field not transferring when forwarding vCard Using Outlook 6
J Meeting Invites Go Blank When Forwarding or Accepting Using Outlook 2
A Emails automatically forwarding but no rule to turn off Using Outlook 2
T Adding text to forwarding rules in Outlook 2010 Using Outlook 1
T Adding tex to forwarding rules in Outlook 2010 Exchange Server Administration 1
L Forwarding an expiring message Using Outlook 0
T To: and Cc: not displaying when forwarding/replying to .eml files Using Outlook 4
V Reply Arrow Icon appears when both Replying or Forwarding Using Outlook 3
C forwarding from 365 to hotmail account? Using Outlook 1
F VB Script, remove text from subject line when forwarding Using Outlook 22
C Forwarding Outlook 2003 calendar items Using Outlook 1
B Outlook 2003 randomly not auto forwarding Using Outlook 0
M Forwarding vCard prompts Send As (From field) on Contacts that were moved Using Outlook 6
B OL2010 - signatures while forwarding tasks or appointments Using Outlook 2
D Private messages not forwarding by rule? Outlook 2007 Using Outlook 1
T [outlook-users] e masil forwarding Using Outlook 2
A Font size increases when forwarding emails Using Outlook 1
A Forwarding recurring appointment/meeting Using Outlook 2
A How do I move a message to a folder after forwarding ? Outlook VBA and Custom Forms 6
V Remove old recipients before forwarding Outlook VBA and Custom Forms 1
A How to change message format while forwarding a mail Outlook VBA and Custom Forms 1
T Why do Outlook Desktop 2021 tasks from my wife's email show up in my task pane? Using Outlook 2
A Opening a link from an email automatically Outlook VBA and Custom Forms 0
D Outlook 2021 New email reminder Using Outlook.com accounts in Outlook 0
Rupert Dragwater How do I remove an email ending with @gmail.com Using Outlook 4
M A plug in (or method) to keep email message formatting after it expires Using Outlook 1
L VBA to Triage Incoming Email Outlook VBA and Custom Forms 0

Similar threads

Back
Top