Giancarlo
Guest
|
I have this procedure for open an e-mail:
FMail: TMailItem;
FMail.Display;
FMail.OnClose := DoCloseMail;
FMail.OnReply := DoReplyMail;
FMail.OnReplyAll := DoReplyMail;
FMail.OnBeforeAttachmentSave := DoBeforeAttachmentSave;
Now, when i try to reply to the message, the plugin calls the procedure DoReplyMail
But if i try to save the attachment, the plugin doesn't call the procedure DoBeforeAttachmentSave;
Why?
I need to manage the file attachment before that user open this.
A bit like make antivirus
The attachment is first processed by Antivirus
and only after the user can manage it |
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Hello Giancarlo,
Here's a citation from https://msdn.microsoft.com/en-us/library/office/ff868639.aspx:
This event corresponds to when attachments are saved to the messaging store. The BeforeAttachmentSave event occurs just before an attachment is saved when an item is saved. If a user edits an attachment and then saves those changes, the BeforeAttachmentSave event will not occur at that time; instead it will occur when the item itself is later saved. It also does not occur when the attachment is saved on the hard disk using the SaveAsFile method.
Andrei Smolin
Add-in Express Team Leader |
|
Giancarlo
Guest
|
Therefore?
What I want to accomplish is impossible? |
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Do you talk about intercepting saving an attachment to the file system in Outlook 2010-2016? If so you need to intercept clicking the built-in ribbon button Save As; see the context menu which is open when you right-click an attachment. This button is shown in two Ribbons: OutlookExplorer (this corresponds to showing the attachment in the context menu) and OutlookMailRead. To intercept it, you put a TadxRibbonCommand component onto the add-in module, set TadxRibbonCommand.IdMso='SaveAttachAs', and handle the OnAction event. In the event procedure, you need to check the AttachmentSelection object; see Explorer.AttachmentSelection and Inspector.AttachmentSelection. This object lets you access the attachment selected and analyze it. If required, you can cancel the TadxRibbonCommand.OnAction event.
You need to intercept clicking the Save Attachments button in the same way; IdMso='SaveAttachments'.
Andrei Smolin
Add-in Express Team Leader |
|
Giancarlo
Guest
|
First part: ok i understand
Second part ( In the event procedure, you need to check the AttachmentSelection object; see Explorer.AttachmentSelection and Inspector.AttachmentSelection.)
I don't found AttachmentSelection
procedure TAddInModule.adxRibbonCommand1Action(Sender: TObject; const Pressed: Boolean; var Cancel: Boolean);
begin
Cancel := False;
ShowMessage('attach');
end;
Which adx component contains AttachmentSelection? (TadxRibbonTab, TadxOutlookAppEvents, etc etc)
You need to intercept clicking the Save Attachments button in the same way; IdMso='SaveAttachments'.
Ok, but if the mail cointains a pdf file, i can open it, via double click.
What is the IdMso for this scenario? |
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Hello Giancarlo,
AttachmentSelection was introduced in Outlook 2010. You need to import the corresponding type library and use it if your add-in is loaded in Outlook 2010+.
Giancarlo writes:
What is the IdMso for this scenario?
Check if intercepting and cancelling the BeforeAttachmentRead and BeforeAttachmentPreview events produces the required result.
Andrei Smolin
Add-in Express Team Leader |
|