简体   繁体   中英

Move a conversation from a shared mailbox into a folder within the shared mailbox

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.

At this time it's not possible!

The problem is in the "store" of shared mailboxes. In there the "ConversationView" is not available and this causes the problem with the "SetAlwaysMoveToFolder", because I don't get a "conversation"-object to move.\\

I hope Microsoft will implement this feature soon.

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