A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

ItemAdd



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 23rd 06, 03:29 AM posted to microsoft.public.outlook.program_vba
BlockNinja
external usenet poster
 
Posts: 4
Default ItemAdd

I have been looking over the Internet for a solution in Outlook 2000 that
will let me show a popup window whenever a new email comes in. In the
ThisOutlookSession all I see is an event for Application_NewMail(), but I
have seen Microsoft MVP's on some sites saying that you should use the
ItemAdd event, however I do not see this in Outlook 2000. Did it not come
around until Office XP?

This is my code right now:
Private Sub Application_NewMail()
Dim myitem As Object
Set myitem =
Me.GetNamespace("MAPI").GetDefaultFolder(olFolderI nbox).Items(1)
Dim subj, from As String
subj = myitem.Subject
from = "Receipt"
On Error Resume Next
from = myitem.SenderName
On Error GoTo 0
Shell "c:\mycode\PopupMessage\bin\Debug\PopupMessage .exe """ & from &
""" """ & subj & """", vbNormalNoFocus
Set myitem = Nothing
End Sub

It basically just looks at the first item in the Inbox whenever a NewMail
hits, I then invoke a small Windows app I made in C# (luckily I have Visual
Studio .NET on this computer, just not Office 2003...) that displays the
from/subj for 3 seconds in a small window and quits. I used the On Error b/c
it looks like if the item is a Read Receipt, it doesn't have a SenderName
attached to it.
Ads
  #2  
Old March 23rd 06, 05:49 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default ItemAdd

ItemAdd event *is* exposed in Outlook 2000, but it is the event on the Items
collection (MAPIFolder.Items).
Do not assume that the newly delivered message will be the first (or last)
message in the Inbox.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"BlockNinja" wrote in message
...
I have been looking over the Internet for a solution in Outlook 2000 that
will let me show a popup window whenever a new email comes in. In the
ThisOutlookSession all I see is an event for Application_NewMail(), but I
have seen Microsoft MVP's on some sites saying that you should use the
ItemAdd event, however I do not see this in Outlook 2000. Did it not come
around until Office XP?

This is my code right now:
Private Sub Application_NewMail()
Dim myitem As Object
Set myitem =
Me.GetNamespace("MAPI").GetDefaultFolder(olFolderI nbox).Items(1)
Dim subj, from As String
subj = myitem.Subject
from = "Receipt"
On Error Resume Next
from = myitem.SenderName
On Error GoTo 0
Shell "c:\mycode\PopupMessage\bin\Debug\PopupMessage .exe """ & from &
""" """ & subj & """", vbNormalNoFocus
Set myitem = Nothing
End Sub

It basically just looks at the first item in the Inbox whenever a NewMail
hits, I then invoke a small Windows app I made in C# (luckily I have
Visual
Studio .NET on this computer, just not Office 2003...) that displays the
from/subj for 3 seconds in a small window and quits. I used the On Error
b/c
it looks like if the item is a Read Receipt, it doesn't have a SenderName
attached to it.



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:19 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.