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 once and 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 get fired twice: 2 times after clicking Send
button within attachment reminder. I was expecting only one event like the first Send.
How can I make OnSend
event fire once after the attachment reminder?
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 once for any email and only after the forgotten attachment detection happened. In the mean time, you'll need to come up with a workaround. Depending on what you're trying to do, you may be able to use custom properties API to set a property indicating that message has been processed already to avoid duplicate processing.
You can't - if the message submission is canceled and the message is then resubmitted, the event is fired again. You can have a list of message entry ids that you processed - add the id to that list when OnSend fires, then check if the message is in that list when the event fires again next time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With