Solved

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

Posted on 2013-05-15
2
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what you should include to make the best professional email signature for your organization.
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…

752 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