Solved

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

Posted on 2013-05-15
2
226 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

810 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