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);
    }
    }
  • 相关阅读:
    JS和Flash相互调用
    xml的应用
    随机验证码
    模块 time
    第一天 注册成功
    我的第一篇博客
    git
    2018-02-27
    25
    建站之星
  • 原文地址:https://www.cnblogs.com/superfeeling/p/2344094.html
Copyright © 2011-2022 走看看