Stmp发送邮件-创新互联

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

从策划到设计制作,每一步都追求做到细腻,制作可持续发展的企业网站。为客户提供成都做网站、成都网站建设、网站策划、网页设计、空间域名、雅安服务器托管、网络营销、VI设计、 网站改版、漏洞修补等服务。为客户提供更好的一站式互联网解决方案,以客户的口碑塑造优易品牌,携手广大客户,共同发展进步。

using System.Net;
using System.Net.Mail;
using System.Net.Mime;
namespace Email
{
public partial class SMTP : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnSend_Click(object sender, EventArgs e)
{
string file = Server.MapPath("testXML.xml");
MailMessage myMail = new System.Net.Mail.MailMessage();
string senderText = txtSender.Text.Trim();//获取或设置此电子邮件的发件人地址
string receiverText = txtReceiver.Text.Trim();//获取或设置此电子邮件的收件人地址
string subjectText = txtSubject.Text.Trim();//获取或设置次电子邮件的主题
string bodyText = txtSender.Text.Trim();//获取或设置邮件正文
myMail = new System.Net.Mail.MailMessage(senderText, receiverText, subjectText, bodyText);
//附件
if (ddlAccessories.Items.Count > 0)
{
for (int i = 0; i < ddlAccessories.Items.Count; i++)
{
System.Net.Mail.Attachment myAttachment = new System.Net.Mail.Attachment(Server.MapPath(ddlAccessories.Items[i].Value), System.Net.Mime.MediaTypeNames.Application.Octet);
System.Net.Mime.ContentDisposition disposition = myAttachment.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
myMail.Attachments.Add(myAttachment);
}
}
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("175.191.40.253", 25);
client.Credentials = new System.Net.NetworkCredential("www.459643912380@qq.com", "w123z123q121q31we21233729281812301");
client.Send(myMail);
}
protected void btnTake_Click(object sender, EventArgs e)
{
if (upFile.PostedFile.ContentLength != 0)
{
string clientFileName = upFile.PostedFile.FileName;
string[] strTemp = clientFileName.Split('.');
string upFileExp = strTemp[strTemp.Length - 1].ToString();
string ServerFileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + upFileExp;
upFile.PostedFile.SaveAs(Server.MapPath(ServerFileName));
ddlAccessories.Items.Add(new ListItem(clientFileName, ServerFileName));
if (ddlAccessories.Items.Count > 0)
{
btnDelete.Enabled = true;
}
else
{
btnDelete.Enabled = false;
}
}
}

}
}

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SMTP.aspx.cs" Inherits="Email.SMTP" %>




















ForeColor="White" NavigateUrl="~/Login.aspx">重新登录
ForeColor="White" NavigateUrl="~/SendEmail.aspx">返回首页
ForeColor="White" >邮件群发
ForeColor="White" NavigateUrl="~/AddFriend.aspx">添加好友
ForeColor="White" NavigateUrl="~/FriendInfo.aspx">查看好友 
   

































ErrorMessage="**">
ErrorMessage="格式不正确" ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*">



ErrorMessage="**">
ErrorMessage="格式不正确" ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*">



ErrorMessage="**">




Width="579px">



Width="40px" CausesValidation="False" />






Width="77px" />






文章题目:Stmp发送邮件-创新互联
标题链接:http://hbruida.cn/article/ihphi.html