SOLVED

API / link for a list of Outlook/OWA/Office default folder names/strings

Copper Contributor

I'm trying to build a process that should read emails from default folders like Inbox, Drafts, Sent Items, Etc. To make it generic, I would need a list of the default translation folder names/strings Office/Exchange/Email providers use when the localization attribute changes.

Till now, I haven't found that list/API on my online search, nor either by investigating office files.

Please advice.

15 Replies

@Victor_Ivanidze 

Thank you for your answer, but I don't find a way to have the actual folder name. Instead, it always returns the English folder name.

 

For example, when I tried to print the result of the following line:
Microsoft.Exchange.WebServices.Data.WellKnownFolderName.Inbox

 

The output was "Inbox" even the actual name was "תיבת דואר נכנס" (the translation of inbox to Hebrew).

Hi @sagisela

as far as I understood your initial question, you do not need to know  the real name of the folder.

Just get an ID of the well-known folder Inbox and forget it's name.

I apologize for the misunderstanding.
I need the real folder name. Therefore, I'm asking for a list of the default translation folder names or an API which could provide a default translated folder name by language, which should be something like:
getLocalizedFolderName("Inbox", "Hebrew")
or 
Microsoft.Exchange.WebServices.Data.WellKnownFolderName.Inbox.getLocalizedNameFor("Hebrew")

Yes, but since I'm developing an RPA process using UiPath and using UiPath Email tools for the development, which use the folder name as a filter and can't use the folder id, I haven't found them useful.
And did you asking for help the UIPath support?

@Victor Ivanidze 

I haven't asked for help the UIPath support because I believe Microsoft should offer a solution. That's certainly not the kind of information Microsoft should avoid sharing.

Moreover, I'm sure Microsoft wants us (developers) to be happy and feel comfortable in order to encourage us to keep developing more tools and features for/using Microsoft programs and platforms.

Hi @sagisela, IMHO your approach is a bit strange.

As you know, each folder has a language-independent ID.  You said you want to use 100 different names of Inbox in different languages instead of asking UIPath if they provide a method to get the folder by ID and not by name. MS provides such method in their APIs.  I know nothing about UiPath but if they have the only method to get the folder by name I'd say they are non-professional.

 

 

I haven't said I want to use 100 different names of Inbox in different languages I said that as MS provides an API to get the folder ID they could also provide an API to get the default folder name for a specific language, not only for my specific case but for many others that might need to use those names in other scenarios.
Dear sir, could you please explain why do you want to know the name of Inbox in Russian if you are using Hebrew Outlook? For what?
Yes, Let's consider, for example, that I've used Hebrew Outlook on my computer for a while, then, I've got a new phone and decided I want to improve my Russian, so I have set my new phone in Russian and then automatically my Outlook changed to Russian in my computer too. Because of that, all Outlook folder names changed also.
When filtering by folder name, my process would fail. Yes, if I would use the folder ID instead of the folder name, the process will survive those changes, but if my process also logged every new email with the following message:
"New Email received in " + folder name + " from " + sender name
because the owner wants to analyze his workers' most common language or any other reason he asked me to add these log messages, I need to have the folder name.
Please assist if you can, and if you can't, please stop challenging me in unnecessary explanations.

Hi @sagisela, please don't be offended - I'm really trying to help.

 

You wrote:

Yes, if I would use the folder ID instead of the folder name, the process will survive those changes, but if my process also logged every new email with the following message:
"New Email received in " + folder name + " from " + sender name
because the owner wants to analyze his workers' most common language or any other reason he asked me to add these log messages, I need to have the folder name.

 

Look. If you know the olFolderInbox the 2 strings of VBA code

 

Set objFolder=objNameSpace.GetDefaultFolder(olFolderInbox)

Debug.Print objFolder.Name

 

will give you the language-specifics folder name.

 

I'm a bit tired so it's my last reply. Good luck.

 

 

best response confirmed by sagisela (Copper Contributor)
Solution

@Victor_Ivanidze 

Thank you for your help. I've created the following class which I believe could and should be added to the official API.

 

using System;
using System.Collections.Generic;
using System.Reflection;
using Oulook = Microsoft.Office.Interop.Outlook;

namespace OutlookDefualtFolderNames
{
    public static class OutlookToolsHMS
    {
        private const string k_MapiNamespaceStr = "mapi";
        private static Oulook.NameSpace GetOutlookNameSpace()
        {
            Oulook.Application oApp;
            Oulook.NameSpace oNS;



            // Create the Outlook application.
            // in-line initialization
            oApp = new Oulook.Application();
            // Get the MAPI namespace.
            oNS = oApp.GetNamespace(k_MapiNamespaceStr);

            // Log on by using the default profile or existing session (no dialog box).
            oNS.Logon(Missing.Value, Missing.Value, false, true);

            // Alternate logon method that uses a specific profile name.
            // TODO: If you use this logon method, specify the correct profile name
            // and comment the previous Logon line.
            //oNS.Logon("profilename",Missing.Value,false,true);

            return oNS;
        }
        public static List<string> GetAllDefualtTranslatedFolderNames()
        {
            List<string> folderNames = new List<string>();
            Oulook.NameSpace oNS = GetOutlookNameSpace();

            foreach (var folder in Enum.GetValues(typeof(Oulook.OlDefaultFolders)))
            {
                try
                {
                    folderNames.Add(oNS.GetDefaultFolder((Oulook.OlDefaultFolders)folder).Name);
                }
                catch { }
            }

            return folderNames;
        }

        public static List<string> GetDefualtTranslatedFolderName(string name)
        {
            List<string> folderNames = new List<string>();
            Oulook.NameSpace oNS = GetOutlookNameSpace();
            string folderName;

            foreach (var folder in Enum.GetValues(typeof(Oulook.OlDefaultFolders)))
            {
                try
                {
                    if (folder.ToString().ToLower().Contains(name.ToLower()))
                    {
                        folderName = oNS.GetDefaultFolder((Oulook.OlDefaultFolders)folder).Name;
                        folderNames.Add(folderName);
                    }
                }
                catch { }
            }

            return folderNames;
        }

    }
}
1 best response

Accepted Solutions
best response confirmed by sagisela (Copper Contributor)
Solution

@Victor_Ivanidze 

Thank you for your help. I've created the following class which I believe could and should be added to the official API.

 

using System;
using System.Collections.Generic;
using System.Reflection;
using Oulook = Microsoft.Office.Interop.Outlook;

namespace OutlookDefualtFolderNames
{
    public static class OutlookToolsHMS
    {
        private const string k_MapiNamespaceStr = "mapi";
        private static Oulook.NameSpace GetOutlookNameSpace()
        {
            Oulook.Application oApp;
            Oulook.NameSpace oNS;



            // Create the Outlook application.
            // in-line initialization
            oApp = new Oulook.Application();
            // Get the MAPI namespace.
            oNS = oApp.GetNamespace(k_MapiNamespaceStr);

            // Log on by using the default profile or existing session (no dialog box).
            oNS.Logon(Missing.Value, Missing.Value, false, true);

            // Alternate logon method that uses a specific profile name.
            // TODO: If you use this logon method, specify the correct profile name
            // and comment the previous Logon line.
            //oNS.Logon("profilename",Missing.Value,false,true);

            return oNS;
        }
        public static List<string> GetAllDefualtTranslatedFolderNames()
        {
            List<string> folderNames = new List<string>();
            Oulook.NameSpace oNS = GetOutlookNameSpace();

            foreach (var folder in Enum.GetValues(typeof(Oulook.OlDefaultFolders)))
            {
                try
                {
                    folderNames.Add(oNS.GetDefaultFolder((Oulook.OlDefaultFolders)folder).Name);
                }
                catch { }
            }

            return folderNames;
        }

        public static List<string> GetDefualtTranslatedFolderName(string name)
        {
            List<string> folderNames = new List<string>();
            Oulook.NameSpace oNS = GetOutlookNameSpace();
            string folderName;

            foreach (var folder in Enum.GetValues(typeof(Oulook.OlDefaultFolders)))
            {
                try
                {
                    if (folder.ToString().ToLower().Contains(name.ToLower()))
                    {
                        folderName = oNS.GetDefaultFolder((Oulook.OlDefaultFolders)folder).Name;
                        folderNames.Add(folderName);
                    }
                }
                catch { }
            }

            return folderNames;
        }

    }
}

View solution in original post