sendmail/senddo.aspx.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
namespace kehu.sendmail
{
public partial class senddo : System.Web.UI.Page
{
static string strHost = xxsoft_check.check.getseting("MailServer");//STMP服务器地址
static string strAccount = xxsoft_check.check.getseting("MailServerUserName"); //SMTP服务帐号
static string strPwd = xxsoft_check.check.getseting("MailServerPassWord");//SMTP服务密码
static string strFrom = xxsoft_check.check.getseting("email");
protected void Page_Load(object sender, EventArgs e)
{
txtto.Text = Request.QueryString["email"].ToString();
txtfrom.Text = strFrom;
}
protected void Button1_Click(object sender, EventArgs e)
{
strFrom = txtfrom.Text.Trim(); //发送方邮件地址
string content = txtcontent.Text.Trim();
string toemail = txtto.Text.Trim();
string title = txttitle.Text.Trim();
try
{
Console.WriteLine(sendMail(toemail, title, content) ? "Success" : "Unsuccess");
Console.ReadLine();
//Response.Write("<script>alet('发送成功!');</script>");
lblMsg.Text = "<font color=red>发送成功!!</font>";
//Response.Redirect("OK.aspx");
}
catch (Exception ex)
{
lblMsg.Text=ex.Message;
}
}
/// <summary>
/// 发送邮件using System.Net.Mail;
/// </summary>
/// <param name="to">接收方邮件地址</param>
/// <param name="title">邮件标题</param>
/// <param name="content">邮件正文内容</param>
/// <returns></returns>
/// <author>xile</author>
/// <date>2010-01-01</date>
static bool sendMail(string to, string title, string content)
{
SmtpClient _smtpClient = new SmtpClient();
_smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
_smtpClient.Host = strHost; ;//指定SMTP服务器
_smtpClient.Credentials = new System.Net.NetworkCredential(strAccount, strPwd);//用户名和密码
MailMessage _mailMessage = new MailMessage(strFrom, to);
_mailMessage.Subject = title;//主题
_mailMessage.Body = content;//内容
_mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//正文编码
后面还有 14 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
