k4j8 / outlook-move-to-thread

Microsoft Outlook VBA to move emails to the same folder as the rest of the email thread
MIT License
32 stars 7 forks source link

Issue with types in Outlook 365 #7

Closed vitaliJJ-source closed 3 years ago

vitaliJJ-source commented 3 years ago

Hi Kyle,

I was using your great tool since a while, however since yesterday I run an update on Outlook, now it stuck here -> in second line:

Dim theConversation As Outlook.conversation
Set theConversation = selectedItem.GetConversation

The message by debugger: "Run Time error 13, type mismatch." I am not sure what is going on here.

I would appreciate If you could look into this.

Best regards, JJ

k4j8 commented 3 years ago

I'm using Outlook 2016 and don't get this error. I'm guessing you have a different version. Could you run a quick test for me?

Add a break into the code on the Set theConversation... line by clicking on the left side of the line (red arrow). Then, run the macro on an email. When the macro pauses at the breakpoint, activate the locals window if it isn't already shown (in VBA toolbar, View -> Locals Window). I'd like to know what the properties of selectedItem are, specifically any properties related to the conversation (such as those marked by the red box). Thanks and I'm glad you (were) finding the macro useful.

conversation properties screenshot

vitaliJJ-source commented 3 years ago

Hi Kyle, thank you for your quick reply. It looks very similar to your picture: image I don't know if theConverstation is OK: image

vitaliJJ-source commented 3 years ago

Hi Kyle, it took me a while. I found a workaround, I used an example from MSDN: https://docs.microsoft.com/de-de/office/vba/api/outlook.conversation.getalwaysmovetofolder. And just stick to their variable names. In my opinion it seems to be that theConversation is kind of reserved. It is working now.

This is the section, I had also to replace a few "oConv" below.

`Public Sub GetConverstationInformation()

 Dim oMail As Outlook.MailItem
 Dim oConv As Outlook.Conversation
 Dim oStore As Outlook.Store

 ' Get Item displayed in Reading Pane.

 Set oMail = ActiveExplorer.Selection(1) '

 Set oStore = oMail.Parent.Store '
 If oStore.IsConversationEnabled Then '

 Set oConv = oMail.GetConversation '
 Debug.Print ("Selected item: " & oMail.ConversationTopic) '

        If Not IsNull(oConv) Then`
k4j8 commented 3 years ago

Great find! When I get the time I'll test myself, but I did notice theConversation was of type SolutionsModule for you whereas for me it was Conversation, which matches the dim statement above it. Thanks for your research, I'll see if I can make updates to fix the macro for everyone.