OnSend fired twice after attachment reminder
Asked Answered
S

2

9

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?

Skillet answered 3/8, 2017 at 15:55 Comment(0)
B
4

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.

Bisector answered 15/8, 2017 at 23:7 Comment(0)
C
1

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.

Chord answered 3/8, 2017 at 16:31 Comment(3)
If I click Send button within the attachment reminder, OnSend will fire 2 times (without counting the first OnSend event)Skillet
Is not about to handle the issue, it is about the fact that OnSend fired twice is not expected behavior. When I said twice it means 2 times after clicking Send button from attachment reminder without counting the first OnSend (before attachment reminder) which is expected to fire only once.Skillet
If you want to have it fixed, you need to open a support case with Microsoft. Posting about this issue on SO won't do anything.Chord

© 2022 - 2024 — McMap. All rights reserved.