![]() |
#2
|
||||
|
||||
![]()
Try the following (processing from end to start):
Code:
Dim olApp As Object Dim olNS As Object Dim olItems As Object Dim olItem As Object Dim bStarted As Boolean Dim i As Long On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If Err <> 0 Then Set olApp = CreateObject("Outlook.Application") bStarted = True End If On Error GoTo 0 Set olNS = olApp.GetNamespace("MAPI") Set olItems = olNS.GetDefaultFolder(6).Items 'Default inbox For i = olItems.Count To 1 Step -1 Set olItem = olItems(i) 'Do stuff with olitem e.g. MsgBox olItem.Subject Next i CleanUp: If bStarted = True Then olApp.Quit End If Set olApp = Nothing Set olNS = Nothing Set olItems = Nothing Set olItem = Nothing lbl_Exit: Exit Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Tags |
email, inbox items, vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
cnaab | Mail Merge | 1 | 11-01-2014 12:45 AM |
![]() |
megatronixs | Outlook | 6 | 10-23-2014 06:42 AM |
Emails do not shoe in sent items | asekely | Outlook | 0 | 07-26-2013 08:52 AM |
Export Outlook emails to Access & parse certain text elements | smahale | Outlook | 0 | 01-18-2012 09:30 PM |
Outlook 2007 Saved sent items list only holds the last ten items | david.peake | Outlook | 0 | 06-01-2010 07:27 PM |