Alternative for Folder.WellKnownFolderName for older Exchange versions - exchange-server

I use Folder.WellKnownFolderName to detect folder type, but it was introduced only in Exchange 2013. Also it doesn't work with "Clutter" folder. Can i use another Folder property to determinate exchange folder type?

Take a look at the FolderClass property. That tells you the type of folder (Mail, Calendar, etc.).

Iterate through all the WellKnownFolderNames you care about, and fetch the corresponding Folders individually by passing Folder.Bind a FolderId created with the constructor that takes a WellKnownFolderName. The FolderId of the returned Folder will have its unique ID set. Then just keep track of the FolderId-to-WellKnownFolderName mapping.

Related

How to enumerate values of custom user property in Outlook C#

I have created custom user property in Outlook called "Ownership". When someone from the team claim ownership of an email, person's name is saved as its value.
My question, is there any way to enumerate all the values of this custom property into combo box.
In simple words, get a list of all team members names (whoever has claimed ownership of an email in inbox folder).
I want to do something like this.
Outlook.UserDefinedProperties userDefinedProperties = null;
Outlook.UserDefinedProperty userDefinedProperty = null;
Outlook.MAPIFolder currentFolder = application.ActiveExplorer().CurrentFolder;
mailUserProperties = currentFolder.UserDefinedProperties;
mailUserProperty = mailUserProperties["Ownership"];
// Filling up the combo box
PersonCombo.Items.Add(userDefinedProperty.Value);
I want to use current folder because folder will have all the values while an email can only have one value of the custom property.
If this is not possible, is there any other way to get it done?
Thank you in advance.
There isn't a single query that will return all unique values of a particular named property. The best you can do is search for all items where the property exists (not null), and then build a list of unique values.
I do not think, however, this is a good of storing possible values - it really must be a single source, such as a particular GAL distribution list, or a hidden (associated) message in the folder that stores all possible values in a single property.
Thanks everyone for your input.
At the end, I ended up creating GAL distribution list as Dmitry suggested and used it for my purpose.

Outlook Addin/VSTO/Redemption: CompareEntryIDs() returns false when comparing the StoreID of the same Exchange Shared Folder

My application saves the StoreID and EntryID of an Exchange Shared Folder to subsequently determine if two users have selected the same Exchange Shared Folder.
For the same Shared Folder, the Exchange users are given StoreIDs that, when decoded as a hex string, looks like this:
?8¡»å¡»+*VÂEMSMDB.DLLƒªf͛Ȫ/ÄZDC/o=TEST/ou=first administrative group/cn=Recipients/cn=UserA
?8¡»å¡»+*VÂEMSMDB.DLLƒªf͛Ȫ/ÄZDC/o=TEST/ou=first administrative group/cn=Recipients/cn=UserB
I would expect CompareEntryIDs() to return true when given the two different EntryIDs, as they refer to the same Shared Folder, but instead it is returning false.
Any ideas as to why CompareEntryIDs() is unexpectedly returning false?
Well, the first entry id is for userA, the second one is for userB. So they are different.

SharePoint Business Connectiviy Data Model Update method failing

I have an external list in SharePoint that references a BCDM I created inside visual studio. The entity as an ID that is auto generated in the database, which means it's read-only.
Create and read method works fine, I'm trying to implement the update method. I have set an input parameter that match my entity and I'm getting this error.
Failed to update a list item for this external list based on the Entity(External Content Type) ‘Notification’ in EntityNamespace ‘Namespace’. Details: The TypeDescriptor with name ‘Id’ in the Method ‘Microsoft.SharePoint.BusinessData.MetadataModel.Static.Method’ on Entity (External Content Type) with Name ‘Namespace’ in Namespace ‘Notification’ is marked ‘PreUpdaterField’, but is contained by another TypeDescriptor marked ‘PreUpdaterField’.
I tried every possible combinaison to make this work, make the id type descriptor read only, pre-updater field = true/ false/, updater field = true/false, removing it, adding another parameter outside the entity. NOTHING WORKS !!! Obviously, I'm about to commit a murder as something so simple just turned out to be the biggest waste of time in my programmation history. What can I do to make this works??
This has been resolved and is explained here:
http://www.dotnetmikael.com/2014/02/sharepoint-2013-bcdm-with-visual-studio.html

Converting Folder ID from EWS to Exchange Cmdlet's Identity

Using Managed EWS 2.0, I'm trying to write some code to create, delete and mail-enable Public Folders on Exchange 2010. However, according to Exchange MVP Glen Scales, mail-enabling a folder is only possible using PowerShell cmdlets, which can be invoked from my C# code. So far, so good.
However, I'm a bit confused when mapping between my EWS Folder objects (which have a FolderId) and PowerShell's Enable-MailPublicFolder cmdlet, which expects a GUID or a Folder Path as identity parameters. I'm not sure how to map between the two.
EWS has a ConvertIDs method, but that seems to be able to generate various formats (EwsId, EntryId, OwaId) which don't seem relevant to PowerShell.
Apart from manually generating a Folder Path from my given folder, which is easy but feels clunky given that I have an explicit identifier for the folder, is there a way to convert my Folder ID to a format usable by the Exchange Cmdlets?
Ok, with the help of Glen Scales I got this to work. It seems that PowerShell's PublicFolderIdParameter type (the type of the Identity parameter) accepts a sequence of Hexadecimal characters representing the EntryID. So to translate an EWS ID to a PowerShell-accepted ID, we can use this code:
Folder myFolder = Folder.Bind("whatever");
var ewsId = new AlternatePublicFolderId(IdFormat.EwsId, myFolder.Id.UniqueId);
var hexId = _service.ConvertId(ewsId, IdFormat.HexEntryId) as AlternatePublicFolderId;
string idForPowerShell = hexId.FolderId;

How to read Outlook folder with a LINQ query?

I need help or sample code in VB.NET to read a specified outlook folder that is not the inbox or a subfolder of inbox
Say folder name is "foo", how can I rerieve emails with a LINQ query, possibly adding where clause(s) for the from, to, date, subject or body content.
Thanks :-)
No offense, but when you have a hammer, everything looks like a nail :-)
Why does it need to be LINQ? It might look neat in you source code, but it can bring your application down to its knees - if you need any kind of restriction, use the native methods whenever you can. In your case, that would be Items.Find/FindNext/Restrict.
If you need to access an arbitrary folder, use the Namespace.Folders collection – it contains top level folders from all stores.
If the folder is on the same level as the Inbox, use Inbox.Parent.Folders collection.
You can use the following.
http://www.nuget.org/packages/scipbe.common.office/
Add it to your project and you can use linq like syntax with outlook.
Also
http://programmersunlimited.wordpress.com/2011/01/08/linqqer-exposing-linq-extensions-on-non-ienumerableiqueriable-collections/

Resources