Select Outlook Folder via COM

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ShubhamM
Posts: 38
Joined: 08 Nov 2017, 21:38

Select Outlook Folder via COM

Post by ShubhamM » 30 May 2022, 17:27

Good Day,

I am trying to open an Outlook folder based on a user input. I have the following code, which does display the folder but opens it in a new window. How do I adjust this such that a new window is not opened and just active explorer/selection changes to the folder I wish to have displayed?

Code: Select all

User_Input := "Client Projects"

Outlook_App := ComObjActive("Outlook.Application")
Namespace := Outlook_App.GetNamespace("MAPI")
Inbox_Folder := Namespace.GetDefaultFolder(6)

Folder_To_Open := Inbox_Folder.Folders(User_Input)
Folder_To_Open.Display
Return
Thanks for any help you are able to provide! Have a great day!

bjagasia
Posts: 1
Joined: 11 Jun 2022, 10:52

Re: Select Outlook Folder via COM

Post by bjagasia » 11 Jun 2022, 12:54

I'd love to know how to do this too!

ronstudy1
Posts: 1
Joined: 23 Mar 2023, 17:58

Re: Select Outlook Folder via COM

Post by ronstudy1 » 23 Mar 2023, 18:05

change "inboxSubFolderName" to some folder name under Inbox

Code: Select all

olApp := ComObjActive("Outlook.Application")
Explorer := olApp.ActiveExplorer()

Folder := olApp.Session.GetDefaultFolder(6).Folders("inboxSubFolderName")
Explorer.SelectFolder(Folder)

Post Reply

Return to “Ask for Help (v1)”