Click here to Skip to main content
16,021,181 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I send an HTML email from an ASP page when I click a button? An alternative, but less ideal solution, would be to just send the URL of the current ASP page in an email, in which case I would need to know how to do the following from an ASP page:

  1. Get the URL of the current page.
  2. Send an email.

Note that I am too lazy to Google for a solution.

NOTE: I added the above simplification. To see the questioner's original question, highlight the below hidden text:

Dear Team

I Have one Html page and and I wand to send that page through My Emal to other Email after presiing the submitt button.



Or I want to send the url of the current page to another email id.

Request to reply me on may mail, as soon as possible.

I am just sendin you the bassic code and please mail me on [email removed] or [email removed], the asp code for the below mention form.

<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
<H1>Test</H1>
<HR>
<p><font size="6"><b>Sending the page </b></font></p>
<P>
This is an explanation of the purpose of the form ...</P>
<FORM METHOD="POST" ACTION="">
<P>
Please provide the following contact information:</P>
<BLOCKQUOTE>
<TABLE>
<TR>
<TD ALIGN="right">
<EM>Name</EM></TD>
<TD>
<INPUT TYPE=TEXT NAME="Contact_FullName" SIZE=35>
</TD>
</TR>
<TR>
<TD ALIGN="right">
<EM>E-mail</EM></TD>
<TD>
<INPUT TYPE=TEXT NAME="Contact_Email" SIZE=25>
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
<p>Send to Other Email</p>
<BLOCKQUOTE>
<TABLE>
<TR>
<TD ALIGN="right">
<EM>Name</EM></TD>
<TD>
<INPUT TYPE=TEXT NAME="Other_FullName" SIZE=35>
</TD>
</TR>
<TR>
<TD ALIGN="right">
<EM>E-mail</EM></TD>
<TD>
<INPUT TYPE=TEXT NAME="Other_Email" SIZE=25>
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
<INPUT TYPE=SUBMIT VALUE="Submit Form">
<INPUT TYPE=RESET VALUE="Reset Form">
</FORM>
<HR>
</BODY>
</HTML>
Posted
Updated 8-Jan-10 22:15pm
v4

Dim mail As New MailMessage
mail.From = "youraddress@domain.com"
mail.To = toaddress@domain.com
mail.Subject = "Subject"
mail.Body = "----ur message body----"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "LocalServerName"
SmtpMail.Send(mail)
 
Share this answer
 
As the previous poster has already given the code to send an email, here is the code to get the URL of the current page.

<br />
string CurrentURL = Request.AppRelativeCurrentExecutionFilePath.ToString();



or


string CurrentURL = Request.ServerVariables["PATH_INFO"].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900