Or even using:
If Items.Item(i).Class = 43 Then
Set oCurrentEmail = Items.Item(i)
' etc.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Dmitry Streblechenko" wrote in message
...
As Ken has already mentioned, you need to test the Class property using
late binding (note the generic Object below) before you cast a variable to
Outlook.MailItem:
Dim Items As Outlook.Items
Dim DummyItem As Object
Dim CurrentEmail As Outlook.MailItem
set Items = oFolderEMail.Items
iCount = Items.Count
For i = 1 To iCount
set DummyItem = Items.Item(i)
if DummyItem.Class = 43 Then
Set oCurrentEmail = DummyItem
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool