Oulook script - How to find the root folder of a favorite folder

459 Views Asked by At

I am trying to find a way to access the associated public folder of a favorite folder. The goal is to move mails automatically to public folders. In the case where this folder has been defined as favorite, I would like to move the mail to this favorite folder for performance issues.

The related public folder path is simply visible on outlook in the favorite folder properties (right click on folder then properties/summary : the path of the public folder is shown there) but i can't find a way to access the information programmatically...

I would really appreciate your help!

Many Thanks,

Guillaume

2

There are 2 best solutions below

0
On

Sub example1() Dim strFinal As String Dim strline As String

Open "D:\textfile.txt" For Input As #1 While EOF(1) = False Line Input #1, strline If Len(strline) > 24 Then strFinal = strFinal + ModifyColumn(strline) Else strFinal = strFinal + strline + vbCrLf End If Wend strFinal = strFinal Close #1

Open "D:\textfile.txt" For Output As #1 Print #1, strFinal Close #1 End Sub

Function ModifyColumn(ByVal strInput As String) As String Dim arrString() As String Dim strOutput As String 'split the columns arrString = Split(strInput, vbTab) 'concatenate the first 2 column as they are strOutput = arrString(0) + vbTab + arrString(1) + vbTab + arrString(2) 'add 100$ to column3 requirevalue = Left(arrString(3), InStr(1, arrString(3), "|") - 1) last3Digit = Right(requirevalue, 3) If Left(requirevalue, 3) = "max" Then Newvalue = vbTab + "OTPxxxxxx" & last3Digit & "|" & Right(arrString(3), Len(arrString(3)) - InStr(1, arrString(3), "|")) + vbCrLf Else Newvalue = vbTab + arrString(3) + vbCrLf End If strOutput = strOutput & Newvalue 'strOutput = strOutput + Strings.Trim(Str(CDbl(Left(arrString(3), Len(arrString(2)) - 1)) + 100)) + "$" + vbCrLf ModifyColumn = strOutput End Function

2
On

I have used EWS to access the PR_FAV_PUBLIC_SOURCE_KEY by using the ExtendedPropertyDefinition

new ExtendedPropertyDefinition(0x7C02, MapiPropertyType.Binary);

converting it to an entry id should bring you to the correct public folder. Details: http://social.technet.microsoft.com/Forums/de-DE/exchangesvrdevelopmentlegacy/thread/e75940c6-b53b-4260-b12c-6541e4ff8a69

And there are more favorite specific properties, like:

    private ExtendedPropertyDefinition eProp_LevelMask = new ExtendedPropertyDefinition(0x7D03, MapiPropertyType.Integer);
    private ExtendedPropertyDefinition eProp_ShortcutType = new ExtendedPropertyDefinition(0x7D09, MapiPropertyType.String);
    private ExtendedPropertyDefinition eProp_FavParent = new ExtendedPropertyDefinition(0x7D02, MapiPropertyType.Binary);

and

    private ExtendedPropertyDefinition eProp_ShortcutName = new ExtendedPropertyDefinition(0x7C00, MapiPropertyType.String);
    private ExtendedPropertyDefinition eProp_ShortcutAlias = new ExtendedPropertyDefinition(0x7C01, MapiPropertyType.String);