Initializing EasiMAPI type in OnItemSend

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

Initializing EasiMAPI type in OnItemSend
Initializing EasiMAPI type in OnItemSend 
Mervin Pearce


Guest


In this procedure... how would I go about to initialise the IMessage which is of the EasyMAPI library and the OnItemSend function set in Initialiase...

procedure TAddInModule.DoItemSend(ASender: TObject; const Item: IDispatch; var Cancel: WordBool);
var
MsgText: TRwMapiString;
IMessage: IRwMapiMessage;
MessageTextFormat: TRwMapiMessageTextFormat;
begin
if Assigned(Item) then
begin
try
MsgText := IMessage.GetMessageText(MessageTextFormat);
case MessageTextFormat of //
mtfPlainText: begin
ShowMessage('text');
end;
mtfRTF: begin
ShowMessage('rtf');
end;
mtfHTML: begin
ShowMessage('html');
end;
end; // case
finally

end;
end;
end;
Posted 06 Dec, 2005 15:35:15 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Mervin,

See the sample code below. I have take it from our ADX Toys for Microsoft Outlook (Easy MAPI Edition) example.


function TAddInModule.GetActiveMessage: IRwMapiMessage;
var
  OutlookItem: OLEVariant;
begin
  Result := nil;
  try
    MapiSession.Logon;
    if OutlookApp.ActiveExplorer.Selection.Count 
<
 1 then
      raise SysUtils.Exception.Create('There is no active message!');
    OutlookItem := OutlookApp.ActiveExplorer.Selection.Item(1);
    if (OutlookItem.class = olMail) or (OutlookItem.class = olRemote) then
      [B]Result := WrapMapiMessage(MapiSession._MapiSession, OutlookItem.MapiObject)[/B]
    else
      raise SysUtils.Exception.Create('The selected item is not an e-mail message!');
  except
    // NOTE. To avoid an Outlook crash you shoud handle and "stub out" all exceptions.
    on E: SysUtils.Exception do
      ShowErrorDlg(E);
  end;
end;




Posted 07 Dec, 2005 07:18:51 Top