-
How Do I Determine What an Item Is?
The following bit of code loops through an Outlook folder and pulls up the items in it:
Set myNewFolder = myFolder.Folders(y)
x = myNewFolder.Items.Count
'loop through each item in the folder
For i = 1 To x
Set mynewitem = myNewFolder.Items.Item(i)
.
.
.
'mynewitem' will be either a message or a meeting invitation or a meeting invitation response. My question is, how do I determine in code which of the three 'mynewitem' is?
TIA...
-
use the typeof function in vba. here's an example of how you might use it:
[VBA] If TypeOf mynewitem Is Outlook.MailItem Then
'do something
ElseIf TypeOf mynewitem Is Outlook.MeetingItem Then
'do something
ElseIf TypeOf mynewitem Is Outlook.AppointmentItem Then
'do something
End If[/VBA]
-
The Class property is a good indicator too.
[VBA]If Item.Class = olMail Then
MsgBox "I'm a MailItem!"
End If[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules