Solved

Outlook VBA to check if a new file is added to an outlook folder since last check?

Posted on 2010-09-02
5
369 Views
Last Modified: 2012-05-10
How can I make outlook vba check if a new file is added to an outlook folder or not?
0
Comment
Question by:awesomejohn19
  • 3
  • 2
5 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 33590924
Thinking slightly differently - how about detecting the addition of an item to a folder directly?

Chris
0
 

Author Comment

by:awesomejohn19
ID: 33590950
Thanks,

I guess that's ok too. How would we achieve that? :)
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 33590951
The following in thisOutlookSession for example will trigger whenever something is added to the inbox.

Chris
Public WithEvents olkInbox As Outlook.items

Private Sub Application_Startup()

    Set olkInbox = Session.GetDefaultFolder(olFolderCalendar).items

End Sub

Sub olkInbox_ItemAdd(ByVal Item As Object)
    msgbox "Item Added:> " & item.subject
End Sub

Open in new window

0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 33590961
The startup sub needs to be triggered to enable it to work ... and is run whenever outlook restarts - or you can simply run it the first time, and from then on it;'s triggered whenver an item is added.  Of course pretty much any folder can be processed in this way.

Chris
0
 

Author Comment

by:awesomejohn19
ID: 33590965
cool thanks
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

Find out what you should include to make the best professional email signature for your organization.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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