Solved

MapiAddress: Returning MapiRecipDesc problem

Posted on 2000-04-17
1
533 Views
Last Modified: 2012-05-07
I've been calling the MapiAddress function with the code below,

only the problem is retrieving multiple addresses, i can retrieve one, but i get stuck on making an array of it again..

if anyone can help, please..

function TNovaMapi.AddressList: MapiRecipDesc;
var
 Flags     : Cardinal;
 pmrd      : amrd;
 mrd       : PMapiRecipDesc;
 mrd2      : PMapiRecipDesc;
 t         : cardinal;
 I         : integer;
 Success   : Boolean;
begin
 mrd  := @pmrd;
 mrd2 := @pmrd;
 t := 1;
 Success := False;

 case fNMEditFields of
  ef0: i := 0;
  ef1: i := 1;
  ef2: i := 2;
  ef3: i := 3;
  ef4: i := 4;
  else I := 0;
 end;
// Set Flags to use
 Flags := 0;
 if opShowDialogs then Flags := MAPI_LOGON_UI;
 if opUseSeparateSession then Flags := Flags + MAPI_NEW_SESSION;

 case MapiAddress(fMapiSession^,fDlgParent.Handle,@fLstCaption,I,@fToString,0,mrd2^,Flags,0,@t,mrd) of
  MAPI_E_FAILURE: Application.MessageBox(strERROR,'Error: MapiAddress',MB_OK+MB_ICONERROR);
  MAPI_E_INSUFFICIENT_MEMORY: Application.MessageBox(strMEMORYSHORT ,'Error: MapiAddress',MB_OK+MB_ICONERROR);
  MAPI_E_INVALID_EDITFIELDS: Application.MessageBox(strADDR_EDITFLDS ,'Error: MapiAddress',MB_OK+MB_ICONERROR);
  MAPI_E_INVALID_RECIPS: Application.MessageBox(strADDR_RECIP ,'Error: MapiAddress',MB_OK+MB_ICONERROR);
  MAPI_E_INVALID_SESSION: Application.MessageBox(strADDR_SESSION,'Error: MapiAddress',MB_OK+MB_ICONERROR);
  MAPI_E_LOGON_FAILURE: Application.MessageBox(strLOGIN_FAILED,'Error: MapiAddress',MB_OK+MB_ICONERROR);
  MAPI_E_NOT_SUPPORTED: Application.MessageBox(strNO_OP_SUPPORT,'Error: MapiAddress',MB_OK+MB_ICONERROR);
  SUCCESS_SUCCESS: Success := True;
  Else
   Application.MessageBox(strUNKNOWN_ERROR,'Error: MapiAddress',MB_OK+MB_ICONERROR);
 end;

 if success then Result := mrd^;

 MapiFreeBuffer(mrd);
 MapiFreeBuffer(mrd2);
end;


0
Comment
Question by:FallenGod
1 Comment
 
LVL 2

Accepted Solution

by:
Ten13 earned 50 total points
ID: 2731481
You cannot return the array of recipients. You have to process the array of recipients and then call MAPIFreBuffer. Eg:

var
  pNewRecipients : PMapiRecipDesc;

  MAPIAddress(fMapiSession^,fDlgParent.Handle,@fLstCaption,I,@fToString,0,mrd2^,Flags,0,@t,mrd); // your call
  pNewRecipients:= mrd;
  for n:= 1 to t do begin
    GetRecipentInfo(pNewRecipients^);
    Inc(pNewRecipients, 1);
  end;
  MAPIFreeBuffer(mrd);

The definition of GetRecipentInfo looks like this:
procedure GetRecipentInfo(mrd : TMapiRecipDesc);

Thats it. No more no less. Good luck!

- Martin
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question