Avatar of Afzal Khan
Afzal Khan
Flag for United States of America asked on

Need help to trigger outlook macro automatically when new email comes in Specific folder

Hi Experts ,

I have a  Independent folder in Outlook named "Test" .
I have macro whose work is to get the attachment from "Test" folder emails and save at"EmailAttachments" folder in "MyDocuments"

So the program is working when I manually run the macro , So I need your help to set some program which can run this macro automatically .
The program should run when new email comes in "Test" folder only otherwise if it will check inbox and all outlook then it will be performance issue.

I am using below code in "ThisOutlookSession" but it is checking all incoming emails in outlook , just need to check "Test" folder only.

Private Sub Application_NewMail()
    Call SaveAttachments
End Sub 

Open in new window

Also "Run as Script" is not available.

Appreciate any help in this regard.
VB ScriptOutlookVBA

Avatar of undefined
Last Comment
Afzal Khan

8/22/2022 - Mon
Shimshey Rosenberg

How are the emails getting into the test folder? Is it with a rule?
You can utilize the same rule to run a script.

See this link;
Afzal Khan

Shimshey the emails are coming through Outlook rule , Unfortunately "Run as Script" is not available in outlook due to security reasons.
Shimshey Rosenberg

What are you looking help with? running it only on a specific folder? or running it automatically?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Afzal Khan

I need help to run the macro automatically when new email comes only to that folder"Test" , As of now I am manually running it.
Afzal Khan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question