open up default mail client after button press

G

Guest

I have a button on an ASP.net form, the button invites people to our event,
so in the code behind I do some database calls and verify information, then
invite them. My question is that, we would like to start their default email
client after this button is pressed and is successfull. I am wondering how I
would do this?

So I would basically like to combine the asp.net button and the mailto:
syntax.

thanks
 
K

Ken Cox [Microsoft MVP]

Hi Don,

You could output some Javascript to do it. This seems like a hack but here
goes:


<form id="Form1" method="post" runat="server">
<P>Type 5 in the box and click the button</P>
<P>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
<P>
<asp:HyperLink id="HyperLink1" runat="server" Visible="False"
NavigateUrl="mailto:[email protected]">Comment</asp:HyperLink></P>
</form>


Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
If TextBox1.Text = "5" Then
Dim sb As New System.Text.StringBuilder
sb.Append("<script TYPE='text/javascript'>")
sb.Append("window.location='mailto:[email protected]';")
sb.Append("</script>")
Response.Write(sb.ToString)
End If
End Sub
 
G

Guest

Ken, I don't know if it is a hack or not, but it is exactly what I was
looking for. Thank you very much. You don't know how much time I have been
spending on this. Again thanks.

don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top