?
Solved

NewMail Event not firing

Posted on 2003-03-31
4
Medium Priority
?
550 Views
Last Modified: 2008-03-10
I cannot get the Startup or NewMail events to fire when Outlook opens or receives new mail. I have the following code in "ThisOutlookSession":

Dim WithEvents myOlApp As Outlook.Application

Private Sub Application_Startup()
   Set myOlApp = CreateObject("Outlook.application")
   MsgBox "Startup"
End Sub

Private Sub myOlApp_NewMail()
    MsgBox "New Mail"
End Sub
0
Comment
Question by:bscmis
[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
  • 3
4 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 2000 total points
ID: 8241448
Hello bscmis,

you could try

Private Sub Application_NewMail()
     MsgBox "New Mail"
End Sub

that's all you need to get started, the application object is created with the startup of outlook and because you use it in the thisoutlooksession object the newmail event is triggered by the current application object in the session

HAGD:O)Bruintje
0
 

Author Comment

by:bscmis
ID: 8246181
Thanks bruintje!

I have other code that is more complex and I wanted to simplify it for this question. I was originally using Application_NewMail but I also had code in the general declarations section which seems to have been the culprit.

Once I took out that code it worked like a charm. I hate stuff like that never thought that would have been the problem.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 8247227
:) thanks for the grade. ...

already thought it would be more then that, cause when i ran it here it worked
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Read this checklist to learn more about the 15 things you should never include in an email signature.
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…
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…
Suggested Courses

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