Solved

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

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

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
If you don't know how to downgrade, my instructions below should be helpful.
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 …
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now