C # System.Net.Mail.MailMessage mail

C # System.Net.Mail.MailMessage mail

Part I will suggest culture which can be seen in the use of e-mail System.Web.Mail.MailMessage

, Provides properties and methods for e-mail configuration. Recommended alternative is: System.Net.Mail, The recommended alternative is System.Net.Mail.MailMessage, therefore, our new console Console project, and then add a reference System.Net

code show as below:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
//using System.IO.Pipes;
using System.Net;
using System.Net.Mail;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
 
namespace LongtengSupremeConsole
{
    class Program
    {        
        static void Main(string[] args)
        {
             System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
            //mm.Sender = new MailAddress("[email protected]", "linjie");
            mm.From = new MailAddress("[email protected]", "123");//发送方
            mm.To.Add(new MailAddress("[email protected]", "456"));//接受方
            mm.CC.Add(new MailAddress("[email protected]", "123789 " )); CC side, CC is a carbon copy, copy, and a copy to the meaning 
            mm.Subject = " the Hello! " ; // theme 
            mm.Body = " . Here's the Hello at The MyPhoto! " ; // content 
            mm = .IsBodyHtml to false ; // whether html format 
            mm.Priority = MailPriority.High; // priority 
            Attachment = A new new Attachment ( " MyPhoto.jpg " , System.Net.Mime.MediaTypeNames.Image.Jpeg); // Annex             mm.Attachments.Add (a);//

  
            the SmtpClient Client =new new the SmtpClient (); // SMTP client 
            client.Host = " smtp.aliyun.com " ; // server host 
            client.DeliveryMethod = SmtpDeliveryMethod.Network; // transmission scheme 
            client.Port = 25 ; // port 
            client.Credentials = new new NetworkCredential ( " [email protected] " , " *** " ); // username and password 
            client.Send (mm); 
            Console.WriteLine ( " );Send messages completed !! " 
            the Console.ReadKey (); 
        } 
    } 
}

 

Guess you like

Origin www.cnblogs.com/1175429393wljblog/p/12015385.html
Recommended