zoukankan      html  css  js  c++  java
  • Smtp Client LinkedResource AlternateView

    
    namespace ConsoleApplication
    {
        using System;
        using System.Net;
        using System.Net.Mail;
        using System.Net.Mime;
        public class Class1
        {
            static void Main(string[] args)
            {
                string html = "<html><body><a href=\"http://www.live.com\"><img src=\"cid:attachment1\"></a>";
                html += "<script src=\"cid:attachment2\"></script>中国字";
                html += "<a href=\"http://www.google.com\"><br><img src=\"cid:attachment1\"></a></body></html>";
                AlternateView view = AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html);
                LinkedResource picture = new LinkedResource(@"pic.JPG", MediaTypeNames.Image.Jpeg);
                picture.ContentId = "attachment1";
                view.LinkedResources.Add(picture);
                LinkedResource script = new LinkedResource(@"a.js", MediaTypeNames.Text.Plain);
                script.ContentId = "attachment2";
                view.LinkedResources.Add(script);
                MailMessage mail = new MailMessage();
                mail .AlternateViews.Add(view);
                mail.From = new MailAddress("xxxx@gmail.com", "Microshaoft-gmail");
                mail.To.Add(new MailAddress("yyyy@live.com", "Microshaoft-live"));
                mail.Subject = "Linked Resource Attachment Alternate Views Smtp Client Test " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                SmtpClient client = new SmtpClient("smtp.gmail.com");
                client.Credentials = new NetworkCredential("user","password");
                client.EnableSsl = true;
                client.Send(mail);
                Console.WriteLine("Hello World");
                Console.WriteLine(Environment.Version.ToString());
            }
        }
    }
    
    
  • 相关阅读:
    Redis 分区
    Redis 管道技术
    8完善博客 8-1 博客主页面开发
    7章 Admin
    6章 Models
    开发第一个Template
    云服务器装teamviewer
    Centos搭建图形界面VNC
    创建应用,并了解应用目录下各文件的作用,同时创建第一个文件响应
    setings.py配置文件详解
  • 原文地址:https://www.cnblogs.com/Microshaoft/p/1454532.html
Copyright © 2011-2022 走看看