0
votes

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.

1
Thanks Om3r, but I want to have the conversation in a folder in the shared mailbox, not in the personal. I already got the solution for moving into the personal folder, but I need it moving into a folder in the shared mailbox. And for this I didn't get any solution. - I also tried to change your "move" to a shared folder but didn' get it working.Mike Cheen
Have you tried using recipient email address? rather Postfach Test0m3r
You mean, I should change "Postfach Test" to "[email protected]"? This doesn't work. I simply get no error, but the conversation is still not moved. Only in debugging mode I get an error message: "Runtime error '-2147024809 (80070057)' Sorry, something went wrong. You may want to try again." I didn't find anything helpful about this error message what could have solved my problem.Mike Cheen

1 Answers

0
votes

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.