1)注册成功发送邮件。
前台代码
收信:/asp:TextBox 主题:/asp:TextBox 内容: Width="336px">/asp:TextBox |
</div>
<table id="Table2" runat="server" border="0" cellpadding="0" cellspacing="0" visible="false">
<tr>
<td align="center" style="width: 400px">
<asp:Label ID="Label1" runat="server" ForeColor="Red" Text="恭喜您,发表成功!"></asp:Label><br />
<br />
<asp:Button ID="Button2" runat="server" Text="返回" onclick="Button2_Click" />
</td>
</tr>
</table>
</form>
后台代码
protected void Button1_Click(object sender, EventArgs e)
{
////设置发件人信箱,及显示名字 ,
MailAddress from = new MailAddress("邮箱");
//设置收件人信箱,及显示名字 , "0503班"
MailAddress to = new MailAddress(TextBox1.Text);
//创建一个MailMessage对象
MailMessage oMail = new MailMessage(from, to);
oMail.Subject = TextBox2.Text; //邮件标题
oMail.Body = TextBox3.Text; //邮件内容
oMail.IsBodyHtml = true; //指定邮件格式,支持HTML格式
oMail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");//邮件采用的编码
oMail.Priority = MailPriority.High;//设置邮件的优先级为高
//发送邮件服务器
SmtpClient client = new SmtpClient();
client.Port = 25;
client.Host = "stmp.163.com"; //指定邮件服务器
client.Credentials = new NetworkCredential("邮箱", "密码");//指定服务器邮件,及密码
//发送
try
{
client.Send(oMail); //发送邮件
Label1.Text = "恭喜你!邮件发送成功。";
}
catch
{
Label1.Text = "邮件发送失败,检查网络及信箱是否可用。";
}
oMail.Dispose(); //释放资源
TABLE1.Visible = false;
Table2.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
//返回,继续发送
Response.Redirect(Request.Url.ToString());
TABLE1.Visible = true;
Table2.Visible = false;
}
怎么也发送不成功。
2)像qq空间访问量左上角的数字怎么做出来