My Task: To build an automated task to periodically save gmail report attachments to Win10 folders for further analysis. This is currently done as a manual process. The platform is a local Win10-PC and does not use Outlook365. Local Outlook.exe linked to Gmail.
Powershell 7x/VSCode(1.52) is the platform and various coding strategies have been attempted and failed. Numerous suggestions from Stackoverflow have been studied with no success. The script has loaded ImapX.DLL Version=2.0.0.19
Objective: To navigate to the email SUB FOLDERS and retrieve the content. The code so far can retrieve from the root folder "INBOX" but that is not where the required messages are. Using Outlook rules the incoming messages are routed to the necessary subfolders. 2 required subfolders exist with replica content, either would do. The message subfolders are easily browsable within Outlook 2019.
The code snip so far...This is where things are not doing as expected so the code is in error??? Searching the sub folder is not working. #Get folder/subfolder object containing the emails needed.
*************** Start Of Code
$numberOfMessagesLimit = 15
$MyFilter= $client.folders | Where-Object { $_.path -eq 'INBOX'} #<< Successful
#these test variants of path all will return NULL
#$MyFilter1 = $client.folders | Where-Object { $_.path -eq 'INBOX/Cindy'}
#$MyFilter2 = $client.folders | Where-Object { $_.path -eq '.\\inbox/Cindy'}
#$MyFilter3 = $client.folders | Where-Object { $_.path -eq '.\inbox/Cindy'}
#$MyFilter4 = $client.folders | Where-Object { $_.path -eq 'INBOX/Cynthia Whitburn'}
#$MyFilter5 = $client.folders | Where-Obje`enter code here`ct { $_.path -eq '\\INBOX/Cynthia Whitburn'}
#$MyFilter6 = $client.folders | Where-Object { $_.path -eq '\INBOX/Cynthia Whitburn'}
# Search email threads inside the subfolder
$messages = $MyFilter.search("All", $client.Behavior.MessageFetchMode, $numberOfMessagesLimit) #<< Successful
*************** End Of Code
The first line $MyFilter is successful but the following lines fail by each returning NULL.
To qualify, these path & names exist in the $client.folders object created previously and match exactly as displayed in the object as shown in MyFilter2 and MyFilter5 so notwithstanding all filters* return NULL.
So my ask is for guidance as to how to navigate to the required folder and capture messages within only that folder.
Many Thanks and appreciation for any tips that might be offered. A
Thanks for the member input. So the core of this matter was the client object built from reading the gmail server was by default 'Lazy' which is a parameter of the method '$client.Behavior.FolderTreeBrowseMode = "Lazy" '. Changing to "Full" created a full set of folders that were accessible. Down side is of course a much slower performance. The documentation for this imapX package is a bit short on info so knowing the full set of supported parameter behavior options is a mystery.