I'm looking for some help on some VBA, I managed to use the site to get code working on my personal mailbox but when I applied to a shared mailbox it doesn't work. I looked through several questions and answers but I cant work out the changes I require
It works on personal mailbox moving from Inbox to Inbox Subfolder called Test
The change I need on the Shared Mailbox was to move from Shared Mailbox Inbox to another folder called Complete. This is just another folder in the shared mailbox and isn't a subfolder
Any help is greatly appreciated
Sub MailmoveAP()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim msg As Outlook.MailItem
Dim InboxItem As Object
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set olFolder = objNS.GetSharedDefaultFolder(olFolderInbox)
Set olFolder = olFolder.Folders("Test")
For Each msg In ActiveExplorer.Selection
msg.Move olFolder
Next
End Sub
The NameSpace.GetSharedDefaultFolder method requires two parameters, not a single one like the GetDefaultFolder
does. This method is used in a delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Inbox folder). For example:
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
To get the Complete
folder if it is located on the same level with Inbox
you could use the Parent
object of the Inbox folder and then get a subfolder. See how to Enumerate folders in Outlook and find the required one.
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.