?
Solved

MapiAddress: Returning MapiRecipDesc problem

Posted on 2000-04-17
1
Medium Priority
?
541 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
Ten13 earned 200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 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