zoukankan      html  css  js  c++  java
  • asp .net 发邮件(带附件)测试可用

      string file = @"c:\ok.xls";
          
            string to = "***@sina.com";
            string from = "***@163.com";
            string subject = "dfsdfsafdsfasfds.";
            string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to, subject, body);
            message.From = new MailAddress("***@163.com", "逄瑞锋");

            Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);      
            // Add the file attachment to this e-mail message.
            message.Attachments.Add(data);
            SmtpClient client = new SmtpClient("smtp.163.com", 25);
            // Credentials are necessary if the server requires the client
            // to authenticate before it will send e-mail on the client's behalf.
            client.Credentials = new NetworkCredential("username", "password");

            client.Send(message);
            data.Dispose();

  • 相关阅读:
    常用CDN
    SQL语句小结
    jQuery源码解析----domManip
    服务治理 SpringCloud Eureka
    docker容器操作
    docker镜像操作常用命令
    Maven
    Centos6解决网络不可达
    MyBatis
    SpringMVC
  • 原文地址:https://www.cnblogs.com/ma/p/505334.html
Copyright © 2011-2022 走看看