zoukankan      html  css  js  c++  java
  • 一个.NET发邮件的简单例子

    using System.Web.Mail;

        MailMessage msgMail = new MailMessage(); 
      
        msgMail.To=Tsendto.Text.Trim();

         msgMail.Cc = "webmaster@aspcool.com";

        msgMail.From = Tsendfrom.Text.Trim();
        msgMail.Subject = "Congraculations!"; 
        msgMail.Priority = MailPriority.High;
        msgMail.BodyFormat = MailFormat.Html; //加这一句,可以发html邮件
        string strBody =Tcontext.Text.Trim(); 
             msgMail.Body = strBody;

    msgMail.Attachments.Add(new MailAttachment("e://aaa.jpg")); 
        SmtpMail.SmtpServer = "mail.zhhz.org";

     msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
           msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
          msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here

        SmtpMail.Send(msgMail);
         Response.Write("<script>alert('发送成功')</"+ "script>");

  • 相关阅读:
    java ppt4
    课后作业 2
    课后作业2
    java ppt题目
    CommandParameter设计
    《大道至简》第二章读后感
    8.多态
    7.接口与继承
    6.数组
    字符串
  • 原文地址:https://www.cnblogs.com/superch0054/p/4010267.html
Copyright © 2011-2022 走看看