Solved

MapiAddress: Returning MapiRecipDesc problem

Posted on 2000-04-17
1
537 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 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 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