Jump to content

Accessing Outlook archive folder


Vakari
 Share

Recommended Posts

I've been using a script to scan through my e-mails and do various things. I'm trying to automate folder selection, as the folder never changes.

This is the code I currently use to select it:

$Outlook = ObjGet("", "Outlook.Application")
If Not IsObj($Outlook) Then $Outlook = ObjCreate("Outlook.Application")
$NameSpace = $Outlook.Session
$Folder = $NameSpace.PickFolder
ConsoleWrite($Folder.Name & @CR)

Since the folder never changes, I want to hardcode it so I don't have to select the folder every time I run the program. The other alternative I've found is this:

I modify the code above to:

$Outlook = ObjGet("", "Outlook.Application")
If Not IsObj($Outlook) Then $Outlook = ObjCreate("Outlook.Application")
$NameSpace = $Outlook.Session
$Folder = $NameSpace.PickFolder
ConsoleWrite($Folder.EntryID & @CR)
ConsoleWrite($Folder.StoreID & @CR)

This will give me and EntryID that looks like: 00000010008618103808018310080

and a StoreID that looks like: 000000000000712729701720971279177107101000100011802870370200272000722200

Now I can make a third modification to the code:

$EntryID = "00000010008618103808018310080"
$StoreID = "000000000000712729701720971279177107101000100011802870370200272000722200"

$Outlook = ObjGet("", "Outlook.Application")
If Not IsObj($Outlook) Then $Outlook = ObjCreate("Outlook.Application")
$NameSpace = $Outlook.Session
$Folder = $NameSpace.GetFolderFromID($EntryID, $StoreID)

Now it selects the folder automatically, but only after I ran the second bit of code and found the EntryID and StateID manually. I don't know enough about EntryID and StoreID, and am curious to know if they can change randomly, or create some other unknown issue.

I'm aware of methods to automatically select your Inbox, or other default folders via $NameSpace.GetDefaultFolder, but how do you go about automatically selecting folders that are in an archive you created or in another mailbox?

$Folder.FolderPath in any of the scripts above will return "\\Archive\Renewals". I'm looking for a method that resembles $NameSpace.GetFolderFromPath("\\Archive\Renewals") and I haven't seen anything like it.

It seems like there is something very simple that I am missing, and could use some help in that regard.

Thanks for reading.

Edited by Vakari
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...