How to open an outlook item from the searched result (mapi url)  
Author Message
Tussh





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Hi Everyone !!!

I am totally new to WDS development. I have downloaded WDS SDK and sample application. Using that sample application i learnt a lot but have problem in opening outlook item from the search result's mapi url. Mapi url is like mapi://LocalHost/Default/Mailbox – Some User ($484efb89)/0/Inbox/ /at= :somefile.txt

Some part of this mapi url is encoded i.e. store entry id (Hashnumber) and EntryID (encoded as Unicode string). For detail please check http://www.hide-link.com/ .

In this article i found the decoding algorithms to calculate store hash and to calculate encoded entry id. These algorithms are in c++ but i wanted it in c#.net, can anyone please do for me

So that using OutlookObjectModel and these decoded store entry id and EntryID we will be able to open outlook items. I think so :)))

So anyone please suggest me the way to open outlook item from the searched result (mapi url) or whether i am going in right track

Thanks in advance for your kind reply :)

- Tushar



Windows Search Technologies1  
 
 
Tussh





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Help me plsssss .....

I got the decoding alogorithm for encoded EntryID in c#.net .. it is on - http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=494824&SiteID=1 So i am able to open the outlook items using current active store id :)

But still not getting the decoding algorithm to calculate store hash in c#.net .......... it will be needed because i have 3 profiles and wds is searching all items from these 3 ... so i am unable to open the items other than current profile :( it needs storeid

We need to take decision as early as possible in our organisation ..... that whether we are going to integrate WDS in our application or not

Please do in favour of me ..... Please help me !!!!

Thank you.


 
 
Paul Nystrom - MSFT





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Tussh,

I have requested a sample from our developers. It may take a bit of time to put out, but I'm hoping we can get one for you.

Paul Nystrom - MSFT



 
 
Tussh





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Thanks Paul ....

I am eagerly waiting for the sample :)

Thanking you.

-Tushar Marathe


 
 
Paul Nystrom - MSFT





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Tussh,

In my search for a solution I found that you can't actually decode the store hash - all you can do is reproduce it. We do have some code for reproducing the store hash, but it's written in C++. You could, however, call the C++ code from C#. Would you be willing to do that

Paul Nystrom - MSFT



 
 
Tussh





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Paul,

Yes Paul i will try for it. Could you please give me the code for reporducing the store hash.

Tushar


 
 
sgibson





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Paul,

Yes Paul i will try for it. Could you please give me the code for reporducing the store hash.

Tushar

I just posted asking for this in another thread. I'd also like the code to reproduce the store hash. Hopefully it won't be too difficult to convert it from C++ to C# code...

Thanks!

-Steve


 
 
sgibson





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Hi Paul,

Any luck with this

I really need this so that I can have a treeview with unique values for message stores!

Thanks!

-Steve


 
 
royberg





PostPosted: Windows Desktop Search Development, How to open an outlook item from the searched result (mapi url) Top

Here's some C# code I wrote based on the C++ examples. Many have asked for this, but I've not seen it anywhere.


/// <summary>
/// Computes the store hash.
/// </summary>
/// <param name="storeEID">The store Entry ID.</param>
/// <param name="fileName">Store filename (optional).</param>
/// <returns>The hash, as a string.</returns>
public string ComputeStoreHash(string storeEID, string fileName)
{
int idx = 0; // Index in buffer
uint hash = 0; // The hash
int lengthStoreEID = storeEID.Length / 2; // Length of store EID -- divide by 2 because 2 text characters here represents 1 byte

// --- Pass 1: Main block (multiple of dword, i.e. 4 bytes) ---
int cdw = lengthStoreEID / sizeof(uint); // cdw = Count Double Words (i.e. number of double words in the buffer)
for (int i = 0; i < cdw; i++, idx += 8)
{
int dword = int.Parse(storeEID.Substring(idx, 8), System.Globalization.NumberStyles.HexNumber);
hash = (hash << 5) + hash + (uint)IPAddress.HostToNetworkOrder(dword);
}

// --- Pass 2: Remainder of the block ---
int cb = lengthStoreEID % sizeof(uint); // cb = Count Bytes (i.e. number of bytes left in the buffer after pass 1)
for (int j=0; j < cb; idx++, j++)
{
hash = (hash << 5) + hash + byte.Parse(storeEID.Substring(idx, 2), System.Globalization.NumberStyles.HexNumber);
}

// --- Add store filename (if used) ---
if (!string.IsNullOrEmpty(fileName))
{
foreach (char c in fileName)
{
hash = (hash << 5) + hash + c;
}
}

return hash.ToString("x");
}


/// <summary>
/// Encode Entry ID.
/// </summary>
/// <param name="EID">The Entry ID.</param>
/// <returns>The encoed EID, as a string.</returns>
public string EIDToEncodedStringWDS30(string EID)
{
int lengthEID = EID.Length;
StringBuilder encodedEID = new StringBuilder(lengthEID);
ulong offset = 0xAC00; // Hangul char range (AC00-D7AF)

for (int i = 0; i < lengthEID; i+=2)
{
string hex = EID.Substring(i, 2);
byte oneChar = byte.Parse(hex, System.Globalization.NumberStyles.HexNumber);
encodedEID.Append((char) (oneChar + offset));
}

return encodedEID.ToString();
}