Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to tell if a selected item is a mailtem OL2003

    I have some code that acts on the bodytext of a selected item in an Explorer window. It works really well when the selected item is a MailItem but is dying an ugly death on an email Bounce which I presume is not strictly a MailItem - but rather some sort of container of the real message.

    How do I precheck what type of entity the item within the explorer selection really is?

    The relevant code is
    DIm myitem as MailItem
    Set myItem = myExplorer.Selection.Item(1)
    <I want to insert some sort of check here>
    theirBody = myItem.Body

    and it dies on this kind of message

    Your message did not reach some or all of the intended recipients.

    Subject: Blah Blah Rhubarb
    Sent: 30/03/2007 4:03 a.m.

    The following recipient(s) could not be reached:

    a@b.c on 30/03/2007 4:03 a.m.
    There was a SMTP communication problem with the recipient's email server. Please contact your system administrator.
    <mail.domainname.somewhere #5.5.0 smtp;550 Invalid recipient: <a@b.c>>

    Any light you could shed would be much appreciated. A secondary question is "what kind of message" is one of these, and how would we identify the original message that needed to be re-sent?

  2. #2
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to tell if a selected item is a mailtem OL2003

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    That sorted that out - I appreciate the wisdom

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How to tell if a selected item is a mailtem OL2003

    Use item.Class, the VBA Help defines all the OlObjectClass types:

    If myExplorer.Selection.Item(1).Class = olMail Then

    (You could also use Typename.) Your code is running into olReport Items, a separate Class from Mail Items.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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