Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-05-15
2
Medium Priority
?
235 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 1500 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Mailbox Overload?
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

971 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