C#使用SMTP发信简要代码

C#使用SMTP发信简要代码
private   void  sendMail() // 発信
        {
            
string  ToAddr   =   " <[email protected]><[email protected]> " ;
            
string  Subject  =   " test " ;
            MailMessage objMail    
=   new  MailMessage();
            objMail.BodyEncoding   
=  System.Text.Encoding.GetEncoding( " shift-jis " );
            objMail.Body 
=   " SMTP test " ;
            objMail.To 
=   " [email protected] " ;                           // 宛先
            objMail.From  =   " @XXX.com " ;      // 送信元
            objMail.Subject      =  Subject;                        // 件名
            SmtpMail.SmtpServer  =   " smtp2.XX.co.jp " ;
            SmtpMail.Send(objMail); 
// メール送信実行
            Subject              =   "" ;
        }

你可能感兴趣的:(C#使用SMTP发信简要代码)