Event in outlook application object model to know when the first click happens on message body box? - vsto

I am developing a add-in to perform some actions when the first click happens on the message box in outlook (2013 version). I want to capture the Outlook.MailItem.Recipients as soon as the first click happens on message body box.

Possible approach to do this (just did a quick test, seems to work for 2013):
Register to NewInspector event of the Application object:
Application.Inspectors.NewInspector += ....;
In the event handler, register to the following event:
var editor = newInspector.WordEditor as Word.Document;
editor.Application.WindowSelectionChange += ....;
The handler fires when the selection changes, which is also happening when the user clicks the window.
Please note that you must keep references to all objects in this sample, else the event registrations will get lost.

Related

SAP Business One SDK - System Form Button Event

I was wondering, is it possible to read or modify click event of a button that belongs to a system form in SAP Business One?
Yes, it is. Set up your form type and event type filters appropriately. Then you'll be able to attach an event handler to ItemEvent. When the handler fires, respond to events for the ItemUID of the system button you're interested in. IN your event handlers you'll typically have something like this:
If pVal.FormTypeEx = “150” And pVal.ItemUID = “1” And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.BeforeAction = True Then
'do something
End If
You can find the ID of the button by turning on System Information in the 'View' menu and hovering over the UI element. The ID and some other information is shown in the status bar.
The "OK" and "Cancel" buttons have IDs 1 and 2 on many forms.

Calling saveAsync from Outlook add-in returns warning notification for an event

My Outlook add-in has a compose scenario for an event (extension point : AppointmentOrganizerCommandSurface). The add-in loads the itemId, makes a REST call to the API to get relevant datas from it and save some calculated datas in the CustomProperties field of the item.
The code ends with Office.context.mailbox.item.saveAsync();
Nevertheless, trying to close the event throws a pop-up asking if the user wants to save changes or not.
How could that be since the last executed code is a saveAsync method on the item ?
Edit : the pop-up occurs only using outlook.office.com but doesn't appear on Outlook dekstop.

Intercept OnSend event after attachment reminder

In Outlook Web Add-In, I'm trying to intercept OnSend event which is triggered when sending an email.
I used this example in GitHub which is working fine.
If I include the word "attachment" in the email body and I click Send button, OnSend event is fired for the first time so I can do some processing to email's content. However, after a while, a pop-up modal window shows up with this message:
Attachment reminder
You may have forgotten to attach a file.
with Send and Don't send buttons. If click Send, OnSend event gets fired a second time. This time, It would be useless to repeat the same email processing. So, I'm looking for a way to find out that the second OnSend event is fired after an Attachment reminder.
Is there a way to distinguish between first and second OnSend events?
Thanks for your question, Mhd! This appears to be unintentional behavior, essentially a defect that we will look into fixing. ItemSend event should inter operate with forgotten attachment detection nicely, and should only be raised after the detection happened. In other words, the first event should not be called at all. Is it a problem if you do the processing twice until this issue is resolved?

How to capture the tick event of the task checkbox on 'Outlook Today'? VSTO Add-in

I'm developing an Outlook Add-in, and currently I have no idea on how to capture the task's checkbox (mark complete) tick event -- particularly on the 'Outlook Today' view. I'd like to override it with my own function.
Refer to the attached image as reference to the checkbox being referred to.
Outlook Today Task
The Outlook Today page is not a typical area that can be integrated with. It is possible though, as it is basically an .html page; see: https://technet.microsoft.com/library/cc750169.aspx. However, this is 20 year-old technology...
If you are mainly interested in trapping changes to that task, then you can trap the Items.ItemAdd event for the Tasks folder and do whatever you like with the modified Task.
The Outlook object model doesn't provide anything for the Outlook Today page. It just lists items from your folders. So, you may consider handling the following events to get the job done:
The ItemChange event of the Items class which is fired when an item in the specified collection is changed.
The PropertyChange event of Outlook items which is fired when an explicit built-in property of an object is changed.
Both events are fired when you mark the task as completed. But in case of the PropertyChange event you need to subscribe to each task item individually which is not really convenient.

Events not triggering when using Send To (Mail Recipient)

I have an Outlook VBA form, which (on the initialize event) loads various data into menus.
This works in normal usage, however, if you right click, send to (mail recipient) on a file or Send > Email in Word, when you click the button to load the form, the form displays but nothing in any events trigger either on the form load, or on the various click events.
Can anyone offer an explanation of why and how to work around the issue?
You need to handle the NewInspector event of the Inspectors class.
Outlook inspectors shown using Simple MAPI or mailto link do not fire inspector events. This was done on purpose.
Which particular event are you using?