简体   繁体   中英

forward emails from an outlook folder using vba

Here is the scenario: My Outlook Inbox has a sub-folder called Notice. Every day, I will check and forward notices to my colleague if there is any automated notice in this folder. I would like to run a vba so that it will go into this folder, check inside, and if there is an email then forward, otherwise stop.

I would seek for your assistance on this scenario as I'm quite new to visual basic on outlook. Thank you very much.

Tony

You could create a macro rule when the folder received an email then forward this email.

Please refer to the below code:

Sub ForwardEmail(Item As Outlook.MailItem)
// Determine if it’s an email
If TypeName(Item) = "MailItem" Then
    With Item.Forward
        .Subject = ("ITS - ") & Item.Subject
        .Recipients.Add "backup@email.com"
        ' You need to overwrite the Body or HTMLBody to get rid of the auto signature
        .HTMLBody = Item.HTMLBody ' <-- Or use .Body for Plain Text
        '.Display ' <-- For Debug
        .Send ' <-- Put break here to Debug
End With
End If
End Sub

For more information, please refer to these links:

Otlook vba and rule to forward email message and change subject

VBA Copy sent mail to folder based on key words in subject

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM