创建表格联系我们 [英] creatw form contact us

查看:103
本文介绍了创建表格联系我们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

对不起,我不会说英文.

我想要一个ASP.NET联系表单,该表单允许用户向我们发送一些邮件.

这是我们代码的一部分,但是没有发送邮件.

html:

Hi.

I cant spell english, sorry.

I want an ASP.NET contact form, that allows the users to send us some mail.

This is part of our code, but no mail is sent.

html:

<div>
<table border="0" cellpadding="0" cellspacing="0" dir="rtl" align="right"
style="font-family: tahoma; font-size: 13px; color: #424242; padding-right: 10px; padding-bottom: 4px; background-color: #FFFFFF;"
width="100%">
<tr>
<td style="width: 155px">
your address</td>
<td>
<asp:TextBox ID="txtfrom" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 155px">
your titr</td>
<td>
<asp:TextBox ID="txtxtitr" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 155px">
send to</td>
<td>
<asp:DropDownList ID="drdnsend" runat="server" Font-Names="Tahoma">
<asp:ListItem Value="info@mydomain.com">email1</asp:ListItem>
<asp:ListItem Value="admin@mydomain.com">email2</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 155px" valign="top">
body message</td>
<td>
<asp:TextBox ID="txtbody" runat="server" Height="223px" TextMode="MultiLine"
Width="540px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 155px">
<asp:Button ID="btnsend" runat="server" BackColor="#424242" BorderStyle="None"
Font-Names="Tahoma" Font-Size="11pt" ForeColor="White" Text="send" />
</td>
<td>
</td>
</tr>
</table>
</div>



代码隐藏:



codebehind:

protected void btnsend_Click(object sender, EventArgs e)
{
   MailMessage mailmsg = new MailMessage();
   mailmsg.From = new MailAddress(txtfrom.Text);
   mailmsg.Subject = txtxtitr.Text;
   mailmsg.To.Add(drdnsend.Text);
   mailmsg.Body = txtbody.Text;
   mailmsg.IsBodyHtml = false;
   SmtpClient smtp = new SmtpClient();
   smtp.Host = ("ipaddress");
   smtp.Send(mailmsg);
}



谢谢



Thanks

推荐答案

可能是由于各种原因.您需要一一看待它们.
港口开放吗?防火墙权限到位了吗?
进一步确保已在Web.Config中配置SMTP配置:
It can be because of various reasons. You need to look at them one by one.
Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>


如果需要,请查看此Microsoft Video教程:
使用ASP.NET发送来自网站的电子邮件 [


If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
If needed, there are lots of article on this very site on how to send emails


坦克.
此代码无法正常工作.
我希望用户得到他的看法.
它的代码是什么
谢谢大家.
tanks.
This code does not work properly.
I want user to get his views.
What is the code for it
thank u all.


嗨.
邮件已发送,但收件箱未发送.
hi.
Messages are sent, but the Inbox did not.


这篇关于创建表格联系我们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆