Solved

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

Posted on 2014-01-27
1
137 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Outlook Free & Paid Tools
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

726 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