is there a way to get the smtpaddress for an mapifolder or outlook interop folder given the entryid (or storeid)

if i have the storeid for a mapifolder, selected through the folderpicker from the outlook interop libraries, is there a way for me to get the smtpaddress for that folder?

i know it's in the extended properties, but i was hoping to do it without any heavy parsing or ldap querying.

the reason i need the smtpaddress is in order to connect to the folder via EWS - i'm currently trying to replace our references to outlook interop with exchange web services, and this has become a sticking point, since many of our users have delegate access to mailboxes that don't belong to them

For the mailbox owner, you can either try to read the MAPIFolder.Store property to get to the parent store, then read the PR_MAILBOX_OWNER_ENTRYID property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x661B0102") using Store.PropertyAccessor.GetProperty. You can then use the store owner entry id to call Namespace.GetAddressEntryFromID. Once you have the AddressEntry object, you can use AddressEntry.GetExchangeUser.PrimarySmtpAddress.

Note that PR_MAILBOX_OWNER_ENTRYID property is only available in the online stores. You might want to use Redemption and its RDOExchangeMailboxStore.Owner.SmtpAddress property. RDOExchangeMailboxStore can be retrieved using RDOSession.GetRDOObjectfromOutlookObject(Store) or using RDOSession.GetStoreFromID.

MAPIFolder.EntryID Property (Microsoft.Office.Interop.Outlook , is there a way to get the smtpaddress for an mapifolder or outlook interop folder given the entryid (or storeid) - outlook. Therefore, the EntryID property is not set for an Outlook item until it is saved or sent. The Entry ID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal Folders (.pst) file to another .pst file.

I know it's years later (sorry), but I needed get SMTP addresses for a bunch of mailboxes, and the accepted answer didn't work (because I've got offline stores) so I did the parsing.

public static bool TryGetSmtpAddress(MAPIFolder folder, out string smtpAddress)
{
    smtpAddress = default;

    var storeId = HexToBytes(folder.StoreID);

    // check it's a store entry id
    if (BitConverter.ToUInt64(storeId, 4) != 0x1A10E50510BBA138UL
        || BitConverter.ToUInt64(storeId, 12) != 0xC2562A2B0008BBA1UL) { return false; }

    var indexDn = Array.IndexOf(storeId, (byte)0x00, 60) + 1;
    var indexV3Block = Array.IndexOf(storeId, (byte)0x00, indexDn) + 1;

    // check it's a V3 entry id (with SMTP address)
    if (BitConverter.ToUInt32(storeId, indexV3Block) != 0xF43246E9UL) { return false; }

    var offsetSmtpAddress = BitConverter.ToUInt32(storeId, indexV3Block + 12);

    smtpAddress = BytesToUnicode(storeId, indexV3Block + (int)offsetSmtpAddress);
    return true;
}

private static byte[] HexToBytes(string input)
{
    var bytesLength = input.Length / 2;
    var bytes = new byte[bytesLength];
    for (var i = 0; i < bytesLength; i++) { bytes[i] = Convert.ToByte(input.Substring(i * 2, 2), 16); }
    return bytes;
}

private static string BytesToUnicode(byte[] value, int startIndex)
{
    var charsLength = (value.Length - startIndex) / 2;
    var chars = new char[charsLength];
    for (var i = 0; i < charsLength; i++)
    {
        var c = chars[i] = BitConverter.ToChar(value, startIndex + i * 2);
        if (c == '\0') { return new String(chars, 0, i); }
    }
    return new String(chars);
}

How to get/access all the shared calendars visible in Oulook ?, if i have the storeid for a mapifolder, selected through the folderpicker from the outlook for an mapifolder or outlook interop folder given the entryid (or storeid). Returns a String (string in C#) indicating the store ID for the folder. Read-only.

NZTony's answer in VB.net:

Public Sub test()
        Dim smtpAddress As String
        Dim selectedItem As Outlook.Folder
        smtpAddress = ""
        TryGetSmtpAddress(Application.ActiveExplorer.Selection.Item(1).Parent, smtpAddress)
End Sub

Public Shared Function TryGetSmtpAddress(ByVal folder As MAPIFolder, ByRef smtpAddress As String) As Boolean
        smtpAddress = "default"
        Dim storeId = HexToBytes(folder.StoreID)

        If BitConverter.ToUInt64(storeId, 4) <> &H1A10E50510BBA138UL OrElse BitConverter.ToUInt64(storeId, 12) <> &HC2562A2B0008BBA1UL Then
            Return False
        End If

        Dim indexDn = Array.IndexOf(storeId, CByte(&H0), 60) + 1
        Dim indexV3Block = Array.IndexOf(storeId, CByte(&H0), indexDn) + 1

        If BitConverter.ToUInt32(storeId, indexV3Block) <> &HF43246E9UL Then
            Return False
        End If

        Dim offsetSmtpAddress = BitConverter.ToUInt32(storeId, indexV3Block + 12)
        smtpAddress = BytesToUnicode(storeId, indexV3Block + CInt(offsetSmtpAddress))
        Return True
End Function

    Private Shared Function HexToBytes(ByVal input As String) As Byte()
        Dim bytesLength = input.Length / 2
        Dim bytes = New Byte(bytesLength - 1) {}

        For i = 0 To bytesLength - 1
            bytes(i) = Convert.ToByte(input.Substring(i * 2, 2), 16)
        Next

        Return bytes
End Function

    Private Shared Function BytesToUnicode(ByVal value As Byte(), ByVal startIndex As Integer) As String
        Dim charsLength = (value.Length - startIndex) / 2
        Dim chars = New Char(charsLength - 1) {}

        For i = 0 To charsLength - 1
            Dim c = CSharpImpl.__Assign(chars(i), BitConverter.ToChar(value, startIndex + i * 2))
            If c = vbNullChar Then
                Return New String(chars, 0, i)
            End If
        Next

        Return New String(chars)
End Function

Private Class CSharpImpl
        <Obsolete("Please refactor calling code to use normal Visual Basic assignment")>
        Shared Function __Assign(Of T)(ByRef target As T, value As T) As T
            target = value
            Return value
        End Function
End Class

How to work with Outlook accounts, stores, folders & items: C# code , The Entry ID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal� MAPIFolder. Folders MAPIFolder. Folders public Microsoft.Office.Interop.Outlook.Folders Folders { get; } Remarks. The NameSpace object is the root of all the

Working with the MAPIFolder Object, In Outlook, I can view and access to different calendars shared by other people. My question is simple: how can I access this calendar/folder� is there a way to get the smtpaddress for an mapifolder or outlook interop folder given the entryid (or storeid) 1 Applescript for Outlook 2011 that moves all messages from a specific folder that match a source account to a different folder

[PDF] Outlook Folders, This property is used to get a reference to a Recipient object that represents the current user for the account. SmtpAddress, If you only need the e-� Returns an Items collection object as a collection of Outlook items in the specified folder. Read-only. public: property Microsoft::Office::Interop::Outlook::Items

Outlook 64 Bit : PowerShell, how to get a MAPIFolder by EntryID and StoreID, and how to use Outlook's folder any additional MAPIFolder objects that are subfolders of the given folder. Represents a Microsoft Outlook folder. A MAPIFolder object can contain other MAPIFolder objects, as well as Outlook items. You can navigate nested folders by using a combination of Folders (index), which returns a folder within a name space or another folder, and the Parent property, which returns the containing object.

Comments
  • In general, folders do not have SMTP addresses. Do you mean the folder id?
  • i don't - i mean the smtpaddress of the owner of the mailbox the folder is in. in order to take the entryid property of the mapifolder and convert it to the exchange web service store id, i need to provide the smtpaddress of the owner of the mailbox. here is the enum for the idformat. so that i can convert as here
  • reached the edit limit of the previous comment this is what i wanted to do, but when i use the folderpicker to select a folder in another user's mailbox (which i have access to), i get nothing back for the account
  • this worked like a charm - the only thing id add is that GetProperty returns a byte(), and converting it to string with system.text.encoding doesn't work as expected. rather, you need to use PropertyAccessor.BinaryToString
  • Do not get it to work :( i get back the byte array, but i am not able to convert it to something meaningful
  • If using Redemption is not an option, you can only do it using Extended MAPI (C++ or Delphi only) -the data is stored in the profile section.
  • @Eñaut - as noted above, PR_MAILBOX_OWNER_ENTRYID is only available if the store is not cached. You can also try to parse the store entry id. extract the EX address, then use it to create a GAL entry id.
  • Yes, the store entry id - take a look at it in OutlookSpy: click IMsgStore button, select PR_ENTRYID or PR_STORE_ENTRYID property, see the "Symb" edit box.