Why all folders not included in IPMRootFolder using Redemption? - outlook

I know this wasn't an issue before but suddenly when i look at the folders that are under the RDOPstStore or RDOStore IPMRootFolder now i only get the standard folder names of Inbox, Deleted Items, Outbox, and Sent.
There is an additional custom named folder called "whalley-g" that i need to recursively iterate through.
This was working fine at one point for a year, but now i only get the four folders.
Redemption.RDOSession mySession = new Redemption.RDOSession();
Redemption.RDOPstStore pst = mySession.LogonPstStore(pstToProcess.PSTFullPathAndName, 1, "Outlook", 1, 1);
int numFolders = pst.IPMRootFolder.Folders.Count;
numFolders should be 5 but is only 4. I didn't bother with the recursive code since i just need to get by the fact that it isn't including the custom folder at all.

Related

google drive API search all children file with given folder ID

Here is how my folder is structured in google drive:
Picture
|----------Date1
|-----Pic1.png
|-----Pic2.png
|----------Date2
|-----Pic3.png
|-----Pic4.png
Right now I only have the ID of Picture folder (the parentID folder). Now I want to get Pic1 picture (inside Date1 folder). Is it possible to query only 1 time to get the picture with only the Picture folder's ID or I will have to query multiple times (get the Date1 and Date2 folder ID, then continue querying) ?
Here is my code right now
$imageName= "Pic1" // name of the image I want to find, which is Pic1
$folderId = "PictureFolderId" // Folder Picture's ID
$optParams = array(
'pageSize' => 1,
'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,id,name,size)',
'q' =>"mimeType contains 'image/' AND name contains '".$imageName."' AND '".$folderId."' in parents"
);
$results = $googleDriveService->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
print "No files found.\n";
} else {
// Do something.
}
If I understand you correctly, you want to:
Retrieve all the image files which are descendants (children, grandchildren, etc.) of a certain folder.
You want to retrieve this with a single API call.
Answer:
It is currently not possible to retrieve files in sub-folders with a single call. That's because a File resource (and a "folder" is a File) does not have information on what files are contained in this parent folder (let alone files contained in "sub-folders") and it only has information on the immediate parents of this folder, and not grandparents and so on, so to speak.
In order to retrieve all "descendants" of a certain folder, two main methods can be used (largely based on this answer by pinoyyid):
Method 1. List all folders:
List all folders in your Drive via Files: list, disregarding whether they have the main folder ID in parents. Let's call this list All folders.
Filter All folders, according to whether they have the main folder ID in parents. Let's call this list Direct children.
For each element in Direct children, filter All folders according to whether they have the corresponding direct child in parents. This way, you will retrieve a list of Grandchildren. Repeat the same process for each Grandchildren element, then for each Great-grandchildren and so on, until no folders are left. With this, you will have retrieved all the folders which are descendant of the main folder ID.
Once you have all the descendant folders, you have to make another Files: list to find the images which are children of any of those folders, or from the main folder. The search query could be something like this:
mimeType contains 'image/' AND ('mainFolderId' in parents OR 'descendant1ID' in parents OR 'descendant2ID' in parents OR...)
Note: This method requires less API calls and will be more appropriate if the file tree is relatively large.
Method 2. Iterate recursively:
Use Files: list to list all files in your main folder which are either folders (and so their own children should be listed) or images. In this case, the search query would be something like:
(mimeType = 'application/vnd.google-apps.folder' OR mimeType contains 'image/') AND 'folderId' in parents
For each child returned by this call, check if it's an image (MIME type containing image/) or a folder (MIME type: application/vnd.google-apps.folder). For each folder, list all files contained in it, using the method from previous step.
Repeat these two steps until there is no folder left. All the images you have retrieved are the "descendants" of your main folder.
Notes:
There is an open feature request in Issue Tracker to include ancestors in query searches, which could allow the retrieval of children in subfolders, and making this whole process much more easy. You could click the star on the top left of the referenced page in order to keep track of this request and to help prioritize it:
Issue #111763024. When will you allow us to use "ancestors" field in searches?
Reference:
How do I search sub-folders and sub-sub-folders in Google Drive?

Search folder for unread emails in inbox not including subfolders

I would like to make a search folder for unread emails in the inbox which does not look into subfolders in the inbox.
Right now I have 5-10 subfolders which are automatically filled with news emails from different sources( using ordinary rules), and then I use the top level of the inbox folder as a kind of important email folder. I would like to make a search folder which finds the unread emails in the top level of the inbox folder but ignores everything in the subfolders.
Outlook version: 1808 (I think). It is part of MS office 365 but it does run locally.
You need to use the Application.AdvancedSearch method which performs a search based on a specified DAV Searching and Locating (DASL) search string. The AdvancedSearch method and related features in the Outlook object model do not create a Search Folder that will appear in the Outlook user interface. However, you can use the Save method of the Search object that is returned to create a Search Folder that will appear in the Search Folders list in the Outlook user interface.
The key benefits of using the AdvancedSearch method in Outlook are:
The search is performed in another thread. You don’t need to run another thread manually since the AdvancedSearch method runs it automatically in the background.
Possibility to search for any item types: mail, appointment, calendar, notes etc. in any location, i.e. beyond the scope of a certain folder. The Restrict and Find/FindNext methods can be applied to a particular Items collection (see the Items property of the Folder class in Outlook).
Full support for DASL queries (custom properties can be used for searching too). You can read more about this in the Filtering article in MSDN. To improve the search performance, Instant Search keywords can be used if Instant Search is enabled for the store (see the IsInstantSearchEnabled property of the Store class).
You can stop the search process at any moment using the Stop method of the Search class.
string scope = "Inbox";
string filter = "[UnRead] = true";
Outlook.Search advancedSearch = null;
Outlook.MAPIFolder folderInbox = null;
Outlook.MAPIFolder folderSentMail = null;
Outlook.NameSpace ns = null;
try
{
ns = OutlookApp.GetNamespace("MAPI");
folderInbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
scope = "\'" + folderInbox.FolderPath "\'";
advancedSearch = OutlookApp.AdvancedSearch(
scope, filter, false, advancedSearchTag );
advancedSearch.Save();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "An eexception is thrown");
}
finally
{
if(advancedSearch!=null) Marshal.ReleaseComObject(advancedSearch);
if (folderSentMail != null) Marshal.ReleaseComObject(folderSentMail);
if (folderInbox != null) Marshal.ReleaseComObject(folderInbox);
if (ns != null) Marshal.ReleaseComObject(ns);
}
In the search box type "Read:unread" without quotes
Once located in the folder where you want to search, in the App Outlook Office 365 you can find the filter of unread emails, like this in the following image.

Outlook Object Model ContactItem won't delete

I'm bedeviled by this. I have a c# application that I need to have a backup before I modify my main contact. But it seems that the copy, sticks around no matter what. I'm verifying this by visual check at the contents of my contents folder in Outlook.
I have a simple test case like so...
Application outlookApplication = new Application();
NameSpace outlookNamespace = outlookApplication.GetNamespace("mapi");
outlookNamespace.Logon("", "", true, true);
MAPIFolder Folder = outlookNamespace.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
MAPIFolder Folder2 = Folder.Folders["Test1"];
Items ContactItems = Folder2.Items;
foreach (ContactItem Contact in ContactItems)
{
ContactItem Backup = (ContactItem)Contact.Copy();
Backup.Delete();
break;
}
outlookNamespace.Logoff();
outlookNamespace = null;
If I try to delete it twice, it causes an error.
Even tried moving it to the deleted items folder, but no luck. Outlook 2010. What is going on?
EDIT: WORKAROUND: If I create a new contact and populate from the original, I can delete it just fine.
I'm not familiar with C# syntax, but I suspect it's because you are adding to the Items collection when you create the copy. I would do this:
Before the start of the foreach loop, check the count of ContactItems:
Items ContactItems = Folder2.Items;
' display ContactItems.Count here, is it Console.WriteLine(ContactItems.Count) ??
After creating the copy, check the ContactItems.Count again. If it has increased, then you need to change your loop to a "For i = ContactItems.Count to 1 Step -1" type of loop instead of a foreach loop (sorry, I only know the VB syntax, I don't know the equivalent C# syntax). It has to be a backwards loop.
If that doesn't work, then create a copy and add it to another Contacts folder, that way it won't interfere with the Items collection of the folder you are working with. That is similar to what you are already doing.

Renaming an AD user (CN) VBS

I have tried 2 ways (changing CN parameter and movehere) to rename a user in AD, without success. Everything else works (changing name, surname, alias...)
Help appreciated,
Marius
From the MSDN on IADsContainer::MoveHere:
The IADsContainer::MoveHere method can
be used either to rename an object
within the same container or to move
an object among different containers.
Moving an object retains the object
RDN, whereas renaming an object alters
the RDN.
For example, the following code
example performs the rename action.
set cont = GetObject("LDAP://dc=dom,dc=com")
set newobj = cont.MoveHere("LDAP://cn=Jeff Smith,dc=dom,dc=com", "cn=Denise Smith")

Column Tree Model doesn't expand node after EXPAND_NO_CHILDREN event

I am displaying a list of items using a SAP ABAP column tree model, basically a tree of folder and files, with columns.
I want to load the sub-nodes of folders dynamically, so I'm using the EXPAND_NO_CHILDREN event which is firing correctly.
Unfortunately, after I add the new nodes and items to the tree, the folder is automatically collapsing again, requiring a second click to view the sub-nodes.
Do I need to call a method when handling the event so that the folder stays open, or am I doing something else wrong?
* Set up event handling.
LS_EVENT-EVENTID = CL_ITEM_TREE_CONTROL=>EVENTID_EXPAND_NO_CHILDREN.
LS_EVENT-APPL_EVENT = GC_X.
APPEND LS_EVENT TO LT_EVENTS.
CALL METHOD GO_MODEL->SET_REGISTERED_EVENTS
EXPORTING
EVENTS = LT_EVENTS
EXCEPTIONS
ILLEGAL_EVENT_COMBINATION = 1
UNKNOWN_EVENT = 2.
SET HANDLER GO_APPLICATION->HANDLE_EXPAND_NO_CHILDREN
FOR GO_MODEL.
...
* Add new data to tree.
CALL METHOD GO_MODEL->ADD_NODES
EXPORTING
NODE_TABLE = PTI_NODES[]
EXCEPTIONS
ERROR_IN_NODE_TABLE = 1.
CALL METHOD GO_MODEL->ADD_ITEMS
EXPORTING
ITEM_TABLE = PTI_ITEMS[]
EXCEPTIONS
NODE_NOT_FOUND = 1
ERROR_IN_ITEM_TABLE = 2.
It's been a while since I've played with SAP, but I always found the SAP Library to be particularly helpful when I got stuck...
I managed to come up with this one for you:
http://help.sap.com/saphelp_nw04/helpdata/en/47/aa7a18c80a11d3a6f90000e83dd863/frameset.htm, specifically:
When you add new nodes to the tree model, set the flag ITEMSINCOM to 'X'.
This informs the tree model that you want to load the items for that node on demand.
Hope it helps?
Your code looks fine,
I would use the method ADD_NODES_AND_ITEMS myself if I were to add nodes and items ;)
Beyond that, try to call EXPAND_NODE after you added the items/nodes and see if that helps.

Resources