• How to tell if a selected item is a mailtem OL2003

    Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » How to tell if a selected item is a mailtem OL2003

    Author
    Topic
    #441146

    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)

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

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #1058563

      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.

    Viewing 0 reply threads
    Reply To: How to tell if a selected item is a mailtem OL2003

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: