Solved

How can I ensure "MyEmail" object is not currently displayed in the Preview Pane?

Posted on 2013-05-15
2
220 Views
Last Modified: 2013-05-30
My VB script examines the attachment on certain incoming emails, and deletes them if the attachment is OK.

If the email to be deleted happens to be the one displayed in the Preview Pane, the VB script fails with "Outlook cannot delete this item". (It's usually not, so the script works most of the time).

How can I guarantee that the email I need to delete is NOT the one displayed in the Preview Pane?
0
Comment
Question by:dossbob
2 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
Comment Utility
The following VBA code shows one way ... essentially test the activeinspector to see if it is the same as the item being processed and skip the code if so.

IN this case I preset the mail item being oprocessed ... your existing code will be doing this already and this object is tested against the current inspector.

Dim itm As MailItem

    Set itm = Application.Session.GetDefaultFolder(olFolderInbox).Items(3)
'=================
    If Application.Inspectors.Count > 0 Then
        If itm = Application.ActiveInspector Then
            MsgBox "oops - Skip it"
        Else
            MsgBox "OK - Continue"
        End If
    Else
        MsgBox "OK - Continue"
    End If

Open in new window


Chris
0
 

Author Comment

by:dossbob
Comment Utility
Chris,

Sorry to take so long to get back to this.

Looks like it should work so I'm going to award the points.

Thanks for your help.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Outlook Free & Paid Tools
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now