Home All Groups Group Topic Archive Search About

Auto display of selected incoming email fails

Author
13 Oct 2006 5:36 PM
Richard Lewis Haggard
I've tried to set up a system wherein selected email automatically displays
but I've done something silly and it does not work.

In short, I've declared an Outlook.Items object which is created at start up
time and associated with a mailbox under the Inbox. An event handler for
this mailbox has been added and it will display the email. I've also created
a rule that moves selected emails into this mailbox. The idea is, email
comes in, the rule places the email in the special box and the event handler
gets triggered which displays the item. Good theory, bad practice. It
doesn't work.

Here's the VBA code:

Private WithEvents ItemsAutoDisplay As Outlook.Items


Private Sub Application_Startup()
    Set ItemsAutoDisplay =
Application.Session.GetDefaultFolder(olFolderInbox).Folders("SDG").Items
End Sub


Private Sub ItemsAutoDisplay_ItemAdd(ByVal Item As Object)
    If TypeOf Item Is Outlook.MailItem Then
        Item.Display
    End If
End Sub

--
Richard Lewis Haggard
www.Haggard-And-Associates.com

Author
13 Oct 2006 6:30 PM
Brian Tillman
Richard Lewis Haggard <HaggardAtWorldDotStdDotCom> wrote:

> Here's the VBA code:

news://msnews.microsoft.com/microsoft.public.outlook.program_vba is the
correct newsgroup for programming questions.
--
Brian Tillman

AddThis Social Bookmark Button