Solved

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

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

776 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