Failure to display an email item

  • Thread starter Richard Lewis Haggard
  • Start date
R

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
has been added that is supposed to be invoked when an email is added to
the mail box 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
 
S

Sue Mosher [MVP-Outlook]

You mean "folder" not "mailbox," right?

Does any VBA code run? Did you check the basics at http://www.outlookcode.com/d/vbabasics.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
R

Richard Lewis Haggard

Yes, my VBA code that creates a new signature after each email is sent seems
to execute normally so it is not a permissions failure or a failure to
enable macros problem. I'm wondering if I might have declared the variable
in the wrong place (VBA for Outlook is not my primary programming
environment).
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
You mean "folder" not "mailbox," right?

Does any VBA code run? Did you check the basics at
http://www.outlookcode.com/d/vbabasics.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top