用于发送HTML页面的ASP代码 [英] Asp code for send the Html page
问题描述
当我单击按钮时,如何从ASP页发送HTML电子邮件?一种替代的但不太理想的解决方案是仅通过电子邮件发送当前ASP页的URL,在这种情况下,我将需要知道如何从ASP页执行以下操作:
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:
- 获取当前页面的URL.
- 发送电子邮件.
请注意,我懒于Google寻求解决方案.
注意:我添加了以上简化.要查看发问者的原始问题,请突出显示以下隐藏的文本:
尊敬的团队
我有一个HTML页面,并且我希望在按提交"按钮后通过我的Emal"将该页面发送到其他电子邮件".
或者我想将当前页面的URL发送到另一个电子邮件ID.
要求尽快回复我.
我只是给您发送bassic代码,请用以下提到的表单的asp代码通过[删除电子邮件]或[删除电子邮件]寄给我.
< HTML>
< HEAD>
< TITLE> Test</TITLE>
</HEAD>
< BODY>
< H1>测试</H1>
< HR>
< p>< font size ="6">< b>发送页面</b></font></p>
< P>
这是对形式...</P>
的解释.
< FORM METHOD ="POST" ACTION =">
< P>
请提供以下联系信息:</P>
< BLOCKQUOTE>
< TABLE>
< TR>
< TD ALIGN =正确">
< EM>名称</EM></TD>
< TD>
< INPUT TYPE = TEXT NAME ="Contact_FullName" SIZE = 35>
</TD>
</TR>
< TR>
< TD ALIGN =正确">
< EM>电子邮件</EM>/TD>
< TD>
< INPUT TYPE = TEXT NAME ="Contact_Email" SIZE = 25>
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
< p>发送到其他电子邮件</p>
< BLOCKQUOTE>
< TABLE>
< TR>
< TD ALIGN =正确">
< EM>名称</EM></TD>
< TD>
< INPUT TYPE = TEXT NAME ="Other_FullName" SIZE = 35>
</TD>
</TR>
< TR>
< TD ALIGN =正确">
< EM>电子邮件</EM>/TD>
< TD>
< INPUT TYPE = TEXT NAME ="Other_Email" SIZE = 25>
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
< INPUT TYPE = SUBMIT VALUE =提交表单">
< INPUT TYPE = RESET VALUE =重置表单">
</FORM>
< HR>
</BODY>
</HTML>
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>
推荐答案
将邮件另存为新MailMessage
mail.From =您的地址@ domain.com"
mail.To = toaddress@domain.com
mail.Subject =主题"
mail.Body ="----您的邮件正文----"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer ="LocalServerName"
SmtpMail.Send(mail)
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)
由于先前的发帖人已经给出了发送电子邮件的代码,因此这里是获取当前页面URL的代码.
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();
或
string CurrentURL = Request.ServerVariables["PATH_INFO"].ToString();
or
string CurrentURL = Request.ServerVariables["PATH_INFO"].ToString();
这篇关于用于发送HTML页面的ASP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!