Solved

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

Posted on 2013-05-15
2
229 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
ID: 39170508
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
ID: 39209539
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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