I am using ASP.Net to handle a button click, perform some data updates in the code-behind and then pop open an Outlook mailto window using ClientScript.RegisterStartupScript. I would like to know whether the mail was Sent, or the popup Closed. Is there some way to capture the result of "parent.location='mailto:" and use the result in the code-behind?
I need to know if the user clicked Send on the popup, or just Closed the popup, so I can update data saying it was sent or discard the update of the data because it was not sent (by the user clicking Send, let's please ignore the edge-case of 'something went wrong with transmitting the email'). Either C# or VB answers are fine.
My button click event in the code-behind has this VB, along with code to update the data in SQL:
ClientScript.RegisterStartupScript(Me.GetType(), name, "parent.location='" + emailStr + "'; ", True)
If you are triggering this using a standard mailto
link, as it seems from the example in your title, then once the O/S has opened the default mail client the browser loses control of or contact with that program. mailto
is a one-way street: it just tells the operating system to open a window (or browser tab if the default mail client is a webmail service). This is pretty ancient technology in the history of the web, and there's no available interaction beyond that.
So no - your web application cannot detect whether the user decided to send the email or do anything else in that mail client. The mail client is not part of your web app, and usually not part of the browser at all, so your JS code (which is heavily sandboxed in general anyway, for security reasons) cannot see what it's doing.
Ultimately if you need more certainty/reliability about whether the content of the email was sent to the mailserver, you should send the email from the server-side code.