1
votes

I've been fetching value of the user name from user's profile "PR_DISPLAY_NAME" and set the same value as sender in "PR_SENDER_NAME_X" property value. But it seems outlook 2010\13 always sets the user name as email address at the time of profile creation. Even if we add the user name manually, it is replaced by the email address when outlook profile/account is created.

My questions are - How do I get the actual user's name so that I can set the same as sender name ? How does transport provider set the sender name which is displayed in From field ( "PR_SENDER_NAME_X" property value) when an email is sent? I tried searching any relevant property but couldn't find.

I am connected to exchange server 2k10 through outlook MAPI account.

At this moment I see following possibilities to get the sender name but I don't think these are the right way to fix the problem.

  1. There is profile property PR_PROFILE_USER which consists a DN name. We can extract the user name from this property.

  2. we have the email address, query that in the address book and get the user name from there. But I not sure if address book always keeps the current user

2

2 Answers

0
votes

What kind of MAPI provider is used in the profile? Is it sn Exchange server? Or a POP3/SMTP account? If you look at the profile using IOlkAccountManager (OutlookSpy will show it to you), do oyu see the expected data?

0
votes

After rounds of discussions with Dmitry. I was able to solve my problem as following -

  1. I already had LeagcyDN or exchange name of the user, so from that I created the EntryId of Sender.

  2. Get the IAddrBook* from IMAPSupport as following - lpMAPIsupport->OpenAddressBook(NULL, 0, &lpAddrBook);

  3. Get the MAPI properties of sender from the Addressbook pointer of the user.

  4. Get the PR_DISPLAY property of the sender from MAPI properties.

Perhaps following code will help to understand

    hrRet = lpMAPIsupport->OpenAddressBook(NULL, 0, &lpAddrBook);
    if (SUCCEEDED(hrRet) && lpAddrBook != NULL )
    {
      hrRet = lpAddrBook->OpenEntry(cbEntryID, lpEntryID, &IID_IMAPIProp, 0, &ulEntryType, 
                        (LPUNKNOWN *)&lpMapiProp);

      if (SUCCEEDED(hrRet) && lpMapiProp != NULL )
      {
        HrGetOneProp(lpMapiProp, PR_DISPLAY_NAME_W, true, UserName);
      }
    }

Note - If you don't have LegacyDN then you can extract that from PR_STORE_ENTRYID property of the message.

Thanks Dmitry.