search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

C# SMTP寄送郵件加上附件檔案 – jashliao部落格

C# SMTP寄送郵件加上附件檔案

資料來源:http://blog.xuite.net/chu.hsing/Think/33046869

using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;// namespace SendMailTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                SmtpClient sc = new SmtpClient(“ms14.hinet.net”);//                 sc.Port = 25;
                MailAddress receiverAddress = new MailAddress(“[email protected]”, “潘建誌”);//                 MailAddress senderAddress = new MailAddress(“[email protected]”, “精創”);
                MailMessage mail = new MailMessage(senderAddress,receiverAddress);//                 mail.Subject=”test”;
                mail.Body = “yahoo”;
                mail.IsBodyHtml = true;//                
                Attachment attachment = new Attachment(@”C:\Test\JackyTest.zip”);//                 
                mail.Attachments.Add(attachment);//                 
                sc.Send(mail);//                 Console.WriteLine(“Done.”);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }
    }
}

 

 



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦