Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Jul : MAPI question

www.cryer.info
Managed Newsgroup Archive

MAPI question

Subject:MAPI question
Posted by:"Nindz Kornjaca" (nindzakornja..@nil.ca)
Date:Sat, 22 Jul 2006 22:43:06

I am trying to get all recipients for a message using
IMessage interface. Simply, it always returns empty values for emails and
display names. What's wrong here:
**********************
procedure TMAPIMessage.RefreshRecipients;
const iColsCount = 3;
  ulProperties: array [0..iColsCount-1] of ULONG =
  ($3001,$0C15,$3003);
    //=(PR_DISPLAY_NAME, PR_RECIPIENT_TYPE, PR_EMAIL_ADDRESS);
var
  Tbl: LPMAPITable;
  pCols: LPSPropTagArray;
  pRows: LPSRowSet;
  //ppRows: LPPSRowSet;
  i, j, iCnt: Integer;
  rt: TsxMAPI_MsgRecipientType;
  dw: DWORD;
  s,s2: string;
begin
  //if FNew then Exit;
  for rt:=Low(FRec) to High(FRec) do FRec[rt].Clear;
  pRows := nil;
  pCols := nil;
  try
    IMessage.GetRecipientTable(0, Tbl);
    MAPIAllocateBuffer(sizeof(ULONG) + sizeof(ULONG)*iColsCount, @pCols);
    pCols.cValues := iColsCount;
    for i:=0 to iColsCount-1 do
      pCols.aulPropTag[i] := ulProperties[i];
    Tbl.SetColumns(pCols, 0);
    Tbl.QueryRows($7FFFFFFF, 0, @pRows);
    iCnt := pRows.cRows;
    //ppRows := @pRows;
    j := 1;
    for i:=0 to iCnt-1 do begin
      if pRows.aRow[i].lpProps <> nil then
        begin
        s2 := pRows.aRow[i].lpProps.Value.lpszA;

        dw := pRows.aRow[i].lpProps.Value.l;
        end;
      //s2 := '';//pRows.aRow[i].lpProps.Value.lpszA;
      case dw of
        MAPI_TO: FRec[sxrtTO].Add(s2);
        MAPI_CC: FRec[sxrtCC].Add(s2);
        MAPI_BCC: FRec[sxrtBCC].Add(s2);
      else
        FRec[sxrtTo].Add(s2);
      end;
    end;
  finally
    if pRows<>nil then begin
      iCnt := pRows.cRows;
      for i:=0 to iCnt-1 do MAPIFreeBuffer(pRows.aRow[i].lpProps);
      MAPIFreeBuffer(pRows);
    end;
    if pCols<>nil then MAPIFreeBuffer(pCols);
    Tbl := nil;
  end;
  //FRecFilled := True;

end;

**********************************************************************

Thanks,
Nikola

Replies:

www.cryer.info
Managed Newsgroup Archive