zoukankan      html  css  js  c++  java
  • asp.net发送邮件代码

    直接上代码:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Mail;

    public partial class MailTest : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    MailMessage objMailMessage;
    MailAttachment objMailAttachment;
    // 创建邮件消息
    objMailMessage = new MailMessage();
    objMailMessage.From = "superfeeling@126.com";//源邮件地址
    objMailMessage.To = "superfeeling@126.com";//目的邮件地址,也就是发给我哈
    objMailMessage.Subject = "注册成功";//发送邮件的标题
    objMailMessage.Body = "邮件发送标内容:测试一下是否发送成功!";//发送邮件的内容
    objMailAttachment = new MailAttachment("e:\\logo.rar");//发送邮件的附件
    objMailMessage.Attachments.Add(objMailAttachment);//将附件附加到邮件消息对象中

    objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
    //用户名
    objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "***********") ;
    //密码
    objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "********");

    //SMTP地址
    SmtpMail.SmtpServer = "smtp.126.com";
    //开始发送邮件
    SmtpMail.Send(objMailMessage);
    }
    }
  • 相关阅读:
    201571030142 四则运算
    略读《构建之法》
    基于原型的软件需求获取
    Java实现小学四则运算练习系统(UI)
    Java实现小学四则运算练习
    201571030104+ 快速通读教材《现代软件工程——构建之法》
    对pow函数的思考
    mysql转移后,启动失败问题
    递归
    requests+re(正则)之猫眼top100排名信息爬取
  • 原文地址:https://www.cnblogs.com/superfeeling/p/2344094.html
Copyright © 2011-2022 走看看