D-list items from IMessage

D-list items from IMessage

Post by Maulik Pate » Sun, 13 Jul 2003 02:27:53



Hello !...

As per Dimitry's suggestions :

mTmp1=my_GetCustomProp(imsg,sd,0x00008080,PT_STRING8);  //display name !
mTmp1 will have display name...

using function below ,

string my_GetCustomProp(IMessage* a_pMess, GUID m_gUid, ULONG
a_nPropID,ULONG PropertyType)
{
  LPSPropValue    pProp   = NULL;
  HRESULT      hr    = S_OK;
  string      wsResult;

  ULONG ls=my_GetCustomPropTag(a_pMess,m_gUid,a_nPropID,PropertyType);

  if(ls!=0) {

   hr = HrGetOneProp(a_pMess,ls,&pProp );

   if (FAILED(hr))
   {
    return "";
   }

  }else { return ""; }

  wsResult = pProp[0].Value.lpszA;

  if (pProp)
  MAPIFreeBuffer(pProp);

   return wsResult;

Quote:}

ULONG my_GetCustomPropTag(IMessage* a_pMess,GUID m_gUid, ULONG
a_nPropID,ULONG PropertyType)
{

  LPSPropTagArray    lpPropTags  = NULL;

  MAPINAMEID     nameid = {0}; // 0
  MAPINAMEID *    rgpnameid[1]={&nameid};

  HRESULT      hr    = S_OK;
  ULONG      nPropTag  = 0;

  nameid.lpguid  = (GUID*)&m_gUid;
  nameid.ulKind  = MNID_ID;
  nameid.Kind.lID  = a_nPropID;

  hr = a_pMess->GetIDsFromNames(1,rgpnameid,0,&lpPropTags);
  if (FAILED(hr))
  {
   return 0;
  }

  //nPropTag = CHANGE_PROP_TYPE(lpPropTags->aulPropTag[0], PT_UNICODE); //
do this if you want to get it as a unicode !

  nPropTag = lpPropTags->aulPropTag[0] | PropertyType; //PT_STRING8;

  MAPIFreeBuffer(lpPropTags);

   return nPropTag;

Quote:}

Code above works fine ... for Display Name of a Contact item..
But  a mobile number of a contact item is directly available like this ,

 mTmp1 +=" , ";
 if (props[5].ulPropTag==PR_MOBILE_TELEPHONE_NUMBER) {
    mTmp1 +=props[5].Value.lpszA;
 }

i guess , PR_MOBILE_TELEPHONE_NUMBER is not a Named Property !!!
OR is it ?

when clicking on it  in OutlookSpy , Named Property Section disappears ...

But , for Distribution lists , i have to :

Dimitry : "You can retrieve all the members of a distribution lists in the
contacts folders using
the regular IMessage interface - entry ids of all the dist list members
are stored in the named property with id = 0x8054 and GUID =
{00062004-0000-0000-C000-000000000046}. It is a PT_MV_BINARY property, just
retrieve each element and call IAddrBook::OpenEntry() - you will get back
IMailUser of that member. "

I tried to get all Distribution list items , within IMessage (in
IMAPIFolder)

ULONG my_Get_Dlist_Items(IMAPISession* mapi_session,IMessage* a_pMess)
{

  LPSPropTagArray    lpPropTags  = NULL;

  MAPINAMEID     nameid   = {0}; //0
  MAPINAMEID *    rgpnameid[1]={&nameid};

  HRESULT      hr    = S_OK;
  ULONG      nPropTag  = 0;

  GUID sd2; // {00062004-0000-0000-C000-000000000046} , it's for D-Lists
  sd2.Data1=0x00062004; sd2.Data2=0x0000; sd2.Data3=0x0000;
  sd2.Data4[0]=0xC0; sd2.Data4[1]=0x00; sd2.Data4[2]=0x00;
sd2.Data4[3]=0x00;
  sd2.Data4[4]=0x00; sd2.Data4[5]=0x00; sd2.Data4[6]=0x00;
sd2.Data4[7]=0x46;

  nameid.lpguid  = (GUID*)&sd2;
  nameid.ulKind  = MNID_ID;
  nameid.Kind.lID  = 0x00008054;

  hr = a_pMess->GetIDsFromNames(1,rgpnameid,0,&lpPropTags);
  if(FAILED(hr))
  {
   return 0;
  }

  ULONG ulObjType=0;
  IABContainer *lpContainer=NULL;
  IAddrBook* pAddrBook=NULL;
   LPSPropValue    pProp   = NULL;

  for(int k=0;k<lpPropTags->cValues;k++) {
    nPropTag = lpPropTags->aulPropTag[0] | PT_MV_BINARY;

   hr = HrGetOneProp(a_pMess,nPropTag,&pProp);

   if(lpContainer==NULL){

make_root_container_available(mapi_session,&pAddrBook,&lpContainer,ulObjType
,0L,NULL);
   }

   if(lpContainer)

mapi_ScanAddressBook2(mapi_session,pAddrBook,lpContainer,pProp->Value.bin.cb
,(LPENTRYID)pProp->Value.bin.lpb);
   }

  MAPIFreeBuffer(lpPropTags);

   return nPropTag;

Quote:}

I can't do :  IAddrBook:: OpenEntry on pProp ( After HrGetOneProp) in above
function ....

Using  pProp->Value.bin.cb  &   (LPENTRYID)pProp->Value.bin.lpb
i can't do IAddrBook::OpenEntry .....

Any suggestions ?

Your Previous comments helped a lot ....Thanks...

OutlookSpy is the Great!....

Cheers,

Maulik Patel