how to handle AttachmentAdd

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

how to handle AttachmentAdd
 
rol




Posts: 4
Joined: 2011-11-14
I would need to handle the Outlook (2007 and later) AttachmentAdd-Event with delphi but i have only found sample code for either VB or .NET see here

Is there any possibility to do that?

regards
richard
Posted 24 May, 2012 08:11:56 Top
Andrei Smolin


Add-in Express team


Posts: 14671
Joined: 2006-05-11
Richard,

Here's a raw sketch demonstrating how to connect to the MailItem.AttachmentAdd event of a mail item opened in the active inspector:


var
mail: TMailItem;

{$R *.dfm}

procedure TAddInModule.adxRibbonTab1Controls0Controls0Click(
  Sender: TObject; const RibbonControl: IRibbonControl);
var
IDisp: IDispatch;
IMail: _MailItem;
begin
  if mail <> nil then
    mail.Disconnect;
  IDisp := OutlookApp.ActiveInspector.CurrentItem;
  IDisp.QueryInterface(IID__MailItem, IMail);
  if IMail <> nil then
  begin
    mail := TMailItem.Create(nil);
    mail.ConnectTo(IMail);
    mail.OnAttachmentAdd := DoAttachmentAdd;
  end;
end;

procedure TAddInModule.DoAttachmentAdd(ASender: TObject;
  const Attachment: Attachment);
begin
  ShowMessage('');
end;


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 May, 2012 09:05:35 Top