Solved

MapiAddress: Returning MapiRecipDesc problem

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now