Outlook email sent despite e.Cancel set in the Send event

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

Outlook email sent despite e.Cancel set in the Send event
 
Subscribe
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Ah, I see. You need to use async/await available in .NET 4.5 and above. Or, you can use e.g. a mutex that the background thread uses and the main thread waits for. These constructs raise a question: do you really need to have the background thread?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Sep, 2017 08:36:17 Top
degree




Posts: 34
Joined: 2010-07-27
Yes, we are doing time consuming tasks before the email can be sent. It can take hours, and we can send the email only when the work is done. We can't block the UI for obvious reasons.
Posted 13 Sep, 2017 09:31:49 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
If the task is lengthy, you can save the email, cancel the ItemSend event, close the inspector window, perform the task, modify the email (if required), and, if you still need to send it, do this using MailItem.Send(). This will trigger the ItemSend event; you will need to use a flag to prevent getting in an endless loop. Also, you may need to move the email to a folder and then send it from that folder.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Sep, 2017 11:16:42 Top