msg.SubjectEncoding = System.Text.Encoding.UTF8;//郵件標題編碼
msg.BodyEncoding = System.Text.Encoding.UTF8;//郵件內容編碼
msg.Subject = "您好";//郵件標題
msg.IsBodyHtml = true;//是否是HTML郵件
attach = new Attachment(c:\test.txt); attach.NameEncoding = System.Text.Encoding.UTF8; msg.Attachments.Add(attach);
msg.Body = "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=utf-8\">"; //加上這一段後,發送HTML類型且有夾帶附件的郵件,在Outlook Express查看郵件原始碼就會是Content-Type: text/html; charset=utf-8而不是Content-Type: text/plain; charset=us-ascii,郵件主旨也不會有亂碼的出現。