Query Recipients on Send

Add-in Express™ Support Service
That's what is more important than anything else

Query Recipients on Send
Outlook Question using ADX 
Marc Fisher




Posts: 11
Joined: 2005-05-21
Hi

I would like to query the Recipients table at the point of sending a message but I am having some difficulties and would like to ask some guidance.

Here is my code:

procedure TAddInModule.DoItemSend(Sender: TObject; var Item,
Cancel: OleVariant);
var
IDsp: IDispatch;
RecipientTable: IMapiTable;
Msg: IMessage;
iCount:cardinal;
begin
RecipientTable:=nil;
IDsp := Item;
if Assigned(IDsp) then
try
IDsp.QueryInterface(IID__MAILITEM, msg);
if Assigned(msg) then
begin
if msg.GetRecipientTable(0, RecipientTable ) = S_OK then
begin
if RecipientTable<>nil then
begin
try
RecipientTable.GetRowCount(0, iCount );
ShowMessage( format( 'row count: %d', [iCount] ));
except
ShowMessage( 'GetRowCount failed');
end;
end
else ShowMessage( 'RecipientTable is nil');
end;
end;
finally
end;
end;



RecipientTable is always nil but I don't know why as it is difficult to debug from Delphi.

Any help would be appreciated.

Delphi6 on W2k, Office2k3, OL2k3

Best regards
Posted 23 Jun, 2005 09:16:33 Top
Dmitry Kostochko


Add-in Express team


Posts: 2745
Joined: 2004-04-05
Hi Marc,

IDsp.QueryInterface(IID__MAILITEM, msg);


I think there is a bug here. You are trying to get the Extended MAPI interface but indicate IID__MailItem which is an Outlook Object Model interface. I think you will have to use the MAPIObject property of the _MailItem interface.

Please note that we provide solutions for Extended MAPI for Premium Subscribers only.
Posted 24 Jun, 2005 06:13:13 Top