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 - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

NewMailEx Code runs only once...



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 9th 07, 03:10 AM posted to microsoft.public.outlook.program_forms
Rafael[_2_]
external usenet poster
 
Posts: 28
Default NewMailEx Code runs only once...

I came across the code below and it is by far the most consistent method to
check for new emails that I've found.

Any how, the only problem I have is that it I receive multiple (two) meeting
updates, the code only fires once.

Any help with this will be greatly appreciated.

Code source: http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx

Public WithEvents outApp As Outlook.Application

Sub Initialize_Handler()
Set outApp = Outlook.Application
End Sub

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim mai As Object
Dim myMeeting As Outlook.MeetingItem
Dim intInitial As Integer
Dim intFinal As Integer
Dim strEntryId As String
Dim intLength As Integer
Dim ns As NameSpace
Set ns = Me.GetNamespace("MAPI")
Dim CurAppnt As Outlook.AppointmentItem

intInitial = 1
intLength = Len(EntryIDCollection)
'MsgBox "Collection of EntryIds: " & EntryIDCollection
intFinal = InStr(intInitial, EntryIDCollection, ",")
Do While intFinal 0
strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intFinal -
intInitial))
Set mai = Application.Session.GetItemFromID(strEntryId)
intInitial = intFinal + 1
intFinal = InStr(intInitial, EntryIDCollection, ",")
Loop
strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intLength -
intInitial) + 1)
'MsgBox strEntryId
Set mai = Application.Session.GetItemFromID(strEntryId)

If mai.MessageClass = "IPM.Schedule.Meeting.Request" Then
Set myMeeting = Application.Session.GetItemFromID(strEntryId)
Set CurAppnt = myMeeting.GetAssociatedAppointment(True)

' Do some stuff with associated appointment
CurAppnt.Save

End If
End Sub

Private Sub outApp_NewMailEx(ByVal EntryIDCollection As String)
Initialize_Handler
End Sub

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire NewMail&NewMailEx Event? baryon Outlook - General Queries 0 August 17th 06 04:31 PM
ThisOutlookSession - code runs only once Rafael1119 Outlook and VBA 8 July 17th 06 11:51 AM
Outlook 2003 "find" contacts doesn't work, just runs and runs Tom Stanley Outlook - Using Contacts 1 July 5th 06 03:56 AM
NewMailEx vs. ItemAdd Mark Rae Outlook and VBA 14 June 15th 06 03:07 PM
Code runs in design mode karlman Outlook - Using Forms 2 January 27th 06 05:49 PM


All times are GMT +1. The time now is 08:01 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.