Solved

Trigger a script when mail items are placed into a mail folder

Posted on 2014-01-27
1
136 Views
Last Modified: 2014-02-11
The user is currently moving emails manually (as a manual process) into a mail folder.

We need Outlook to automatically run a script when the emails are placed into that folder.  I saw some posts on .itemadd but need some sample code that will detect when the user moves the emails and then run a script on all emails in that folder.

The script (which we have ready) sends a template reply to all emails in that folder.

We would also like the email to then be moved to a different folder (for archive) once the script is ran per email.

Any ideas on how to set this up?
0
Comment
Question by:jkanisut
1 Comment
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39813255
HI,

pls try something similar in thisOutlook

Private WithEvents olMyFolderItems As Items

Private Sub Application_Startup()
  Dim objNS As NameSpace
  Set objNS = Application.Session
  ' instantiate objects declared WithEvents
  Set olMyFolderItems = objNS.GetDefaultFolder(olFolderInbox)).Folders("MyFolder").Items
  Set objNS = Nothing
End Sub

Private Sub olMyFolderItems_ItemAdd(ByVal Item As Object)
  MsgBox "You've placed an item in the myFolder Folder
  Set Item = Nothing
End Sub

Open in new window

Regards
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question