Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Auckland, North Island, New Zealand
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    additem event failing (vba 6.3 Outlook 2003)

    Public WithEvents myOlItemsSimon As Outlook.Items


    Sub application_startup()
    ...
    with ...
    Set myOlItemsSimon = .Folders("Simon").Items
    ...
    end sub


    Private Sub myOlItemsSimon_ItemAdd(ByVal item As Object)
    ActionOnNewMail item
    End Sub


    Sub ActionOnNewMail(Anyitem As Outlook.MailItem)
    ...
    ...


    The above code snippets worked perfectely in earlier versions of outlook, triggering when new mail was put into the "simon" folder and running ActionOnNewMail.

    In 2003 it has become unstable. It is occassionally stopping on the ActionOnNewMail sub. The item object having no properties (ie trying to expand the "+item" line in Locals window shows nothing underneath this line - would normally see all the mail properties (eg subject, recipients etc))

    I have tried:
    Private Sub myOlItemsSimon_ItemAdd(ByVal item As outlook.items)
    but this does not work.

    Have used "If Anyitem.Class = olMail" but when the obect contains nothing this does not work.

    Is it possible that the aditem is being falsely triggered?

    Any ideas what I can do to get this stable again?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: additem event failing (vba 6.3 Outlook 2003)

    > Have used "If Anyitem.Class = olMail" but when the obect contains nothing this does not work.

    If the problem is that the item isn't always mail, then maybe try it in the myOlItemsSimon_ItemAdd procedure, checking whether item is of the correct type before calling ActionOnNewMail.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •