We have a shared mailbox (test@) with a subfolder (TestIn).
I want to choose an email in the inbox of the shared mailbox and move it to the "TestIn" folder.
This mail should be moved as conversation, not only the single mail, every mail under this Header (conversation) should go into this folder.
We are working with Office365 and Microsoft Exchange Accounts in Outlook.
I got it working to move the selected message (or conversation) from the shared mailbox into a subfolder of the personal mailbox, not the shared one.
Here's the code:
Sub SetAlwaysMoveToFolderMAPI()
Dim sharedemail As Outlook.Recipient
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myMail As Outlook.MailItem
Dim myStore As Outlook.Store
Dim oConv As Outlook.Conversation
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set sharedemail = myNameSpace.CreateRecipient("Postfach Test")
Set myInbox = myNameSpace.GetSharedDefaultFolder(sharedemail, olFolderInbox)
Set myDestFolder = Application.Session.GetDefaultFolder(olFolderInbox).Folders("TestIn")
Set myMail = ActiveExplorer.Selection(1)
Set myStore = myDestFolder.Store
If myStore.IsConversationEnabled Then
Set myConv = myMail.GetConversation
If Not (myConv Is Nothing) Then
myConv.SetAlwaysMoveToFolder myDestFolder, myDestFolder.Store
End If
End If
End Sub
If I replace
Set myDestFolder = Application.Session.GetDefaultFolder(olFolderInbox).Folders("TestIn")
with
Set myDestFolder = myNameSpace.GetSharedDefaultFolder(sharedemail, olFolderInbox).Folders("TestIn")
it doesn't move anything and I don't get any error message.
If I debug I see, that the script is jumping from If myStore.IsConversationEnabled Then
straight to the end.
For me this means, the If myStore.IsConversationEnabled Then
is the problem, but I can't find anything about it.
Postfach Test
– 0m3r