zoukankan      html  css  js  c++  java
  • 找回密码邮件发送类

    简单的代码发送邮件代码:

    private void SendEmail()
        {
             MailMessage objMailMessage;
             Attachment objMailAttachment;
             // 创建一个附件对象
            objMailAttachment = new Attachment("d:\test.txt");//发送邮件的附件
             // 创建邮件消息
             objMailMessage = new MailMessage();
             objMailMessage.From = new MailAddress("chenli3319@gmail.com");//你自己的邮箱地址
    
             objMailMessage.To.Add("mtl8007@sohu.com");//目的邮件地址俺的QQ邮箱
    
             objMailMessage.Subject = "邮件发送标题:你好!";//发送邮件的标题
    
             objMailMessage.Body = "邮件发送标内容:测试一下是否发送成功!";//发送邮件的内容
             objMailMessage.IsBodyHtml = true;
             objMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
             objMailMessage.Priority = System.Net.Mail.MailPriority.Normal;
             objMailMessage.Attachments.Add(objMailAttachment);//将附件附加到邮件消息对象中
             //SMTP地址
             SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");//网络上的代理服务器
             smtpClient.EnableSsl = true;
             smtpClient.Credentials = new System.Net.NetworkCredential(objMailMessage.From.Address, "13630264905");//设置发件人身份的信息
    
             smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    
             smtpClient.Host = "smtp." + objMailMessage.From.Host;
    
             smtpClient.Send(objMailMessage);
        }
    

      

  • 相关阅读:
    初识java反射机制
    基本数据类型-保装类型-string三种数据类型的转换
    java 正则表达式
    java 异常
    java 初识String
    java 接口
    java抽象
    初识多态 简单理解
    初来驾到学JAVA继承初识
    转载:Gearman php
  • 原文地址:https://www.cnblogs.com/double2012/p/3144583.html
Copyright © 2011-2022 走看看