Consulting

Results 1 to 3 of 3

Thread: How Do I Determine What an Item Is?

  1. #1

    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...

  2. #2
    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]

  3. #3
    VBAX Tutor Mavyak's Avatar
    Joined
    Jul 2008
    Posts
    204
    Location
    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
  •