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

Msgbox prompt on Delegate Inbox



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8  
Old September 13th 07, 12:52 AM posted to microsoft.public.outlook.program_vba
Sydney[_2_]
external usenet poster
 
Posts: 5
Default Msgbox prompt on Delegate Inbox

Yayyy... This is now working.
I had an empty Class module, after removing this module and restarting
Outlook it works perfectly... didnt think an empty module would have any
effect but there you go.

Thank you so much for your help


"Sue Mosher [MVP-Outlook]" wrote in message
...
I don't see any problem with the code below. What in particular fails? Does
myRecipient resolve? Does objNS.GetSharedDefaultFolder(myRecipient,
olFolderInbox) return a valid MAPIFolder object?

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Sydney" wrote in message
...
Hi Sue

I guess my major issue is that I cannot adapt my code to work on an
additional mailbox. I have tried a few code sceniarios... all work on my
default inbox.

The latest code from your sample also works perfectly on the default
inbox,
when I try to call the additional mailbox it fails. Here it is and I
haven't given up yet.. any direction would be highly appreciated

Private WithEvents olInboxItems As Items

Private Sub Application_Startup()
Dim objNS As NameSpace
Dim myRecipient As Outlook.Recipient

Set objNS = Application.GetNamespace("MAPI")

Set myRecipient = objNS.CreateRecipient("Barrier Officer") 'added
myRecipient.Resolve 'added

' instantiate objects declared WithEvents
' Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set olInboxItems = objNS.GetSharedDefaultFolder(myRecipient,
olFolderInbox).Items

Set objNS = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
On Error Resume Next

If Item.UnRead Then
MsgBox "You have an unread item in Barrier Inbox"
End If

Set Item = Nothing
End Sub



"Sue Mosher [MVP-Outlook]" wrote in message
...
Did you look at the example I suggested? It -- and the Help topic on
ItemAdd
show how to use it. If there's something you don't understand about the
examples, let's talk about it.

"Sydney" wrote in message
...
Thanks for replying. I am just not sure what lines to put in and where.
Ive tried a few scenarios that have failed.

Would you mind telling what lines I need to include?


"Sue Mosher [MVP-Outlook]" wrote in message
...
You would need to use a different event -- MAPIFolder.Items.ItemAdd -- on
the other mailbox's Inbox. See
http://www.outlookcode.com/d/code/zaphtml.htm
for an example of that event handler that you should be able to adapt.

Also note that you should never use this statement in Outlook VBA code:

Set myOlApp = CreateObject("Outlook.Application")

Instead, derive all Outlook objects from the intrinsic Application
object.


"Sydney" wrote in message ...
Hi all

Using Outlook 2003 vba, I am trying to intercept when new mail arrives
on
an
additional mailbox. I have found code that does exactly what I need
however
it only works on the default mailbox. I tweaked the code from
http://www.vbforums.com/archive/index.php/t-251607.html hoping it will
work
on a delegate Inbox, however it does not run automatically.

Am I wasting my time? Is this possible? ... Thanks in advance.

MY CODE:

''**WORKS WHEN RUN MANUALLY**
Private Sub Application_NewMail()

Dim oInbox As Outlook.MAPIFolder
Dim oEmail As Outlook.MailItem
Dim myNamespace As Outlook.NameSpace

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Barrier Officer")
myRecipient.Resolve
If myRecipient.Resolved Then

Set oInbox = myNamespace.GetSharedDefaultFolder(myRecipient,
olFolderInbox)

If oInbox.UnReadItemCount 0 Then MsgBox "New Email!", vbOKOnly +
vbInformation

Set oInbox = Nothing
Set oNS = Nothing
End If

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
MsgBox Hidden Lionel H Outlook and VBA 3 April 10th 07 04:26 PM
Delegate issue - meetings only show up after delegate opened the request [email protected] Outlook - Calandaring 0 July 21st 06 06:16 PM
Clear multiple MsgBox!!! RemySS Outlook and VBA 4 May 5th 06 09:07 AM
Question on frames and msgbox Jade Outlook - Using Forms 4 April 26th 06 03:12 AM
Outlook 2002 - Delegate updates in delegate calendar? Wazza Outlook - Calandaring 0 February 1st 06 11:20 AM


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