简体   繁体   中英

How to extract email on receive/send to/from shared mailbox in outlook vba?

I have 20 shared mailboxes in my current outlook application. I tried extracting and displaying email by using ItemAdd and ItemSend for current outlook profile which is my personal (nvreddy@domain.com) and succeeded. but when I am tried for shared mailboxes I got failed and no idea where to start to get extraction of email receive and send for share mailboxes.

how can I make sure Outlook VBA to identify and display if any new email receives to any shared mailbox and sends from any shared mailbox. I hope I have explained my best here as I am new bee here.

Thanks in advance.

You need to use the NameSpace.GetSharedDefaultFolder method to get a Folder object that represents the specified default folder for the specified user.

Sub ResolveName() 
 Dim myNamespace As Outlook.NameSpace 
 Dim myRecipient As Outlook.Recipient 
 Dim CalendarFolder As Outlook.Folder 
 
 Set myNamespace = Application.GetNamespace("MAPI") 
 
 Set myRecipient = myNamespace.CreateRecipient("Eugene Astafiev")
 myRecipient.Resolve 
 If myRecipient.Resolved Then 
 Call ShowCalendar(myNamespace, myRecipient)
 End If 
End Sub 
 
Sub ShowCalendar(myNamespace, myRecipient) 
 Dim CalendarFolder As Outlook.Folder 
 
 Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar) 
 CalendarFolder.Display 
End Sub

As soon as you have retrieved an instance of the Folder class you can add an ItemAdd event handler.

The ItemSend event is fired only for the accounts configured in your profile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM