Solved

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

Posted on 2010-09-02
5
367 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

757 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

19 Experts available now in Live!

Get 1:1 Help Now