IPart part = new TKMP.Writer.MultiPart( new text, new html ); としてみたところ、Outlookでの受信では、textが「ATT***.txt」として添付されてしまい、 ヘッダが Content-Type: multipart/mixed; となりました。
以下に試したソースを記載いたします。 ---------------------------------------------------------------------------- /// <summary> html用 </summary> public class HtmlPart : TKMP.Writer.IPart { private TKMP.Writer.TextPart _TextPart;
public HtmlPart(string Text) { _TextPart = new TKMP.Writer.TextPart( Text, TKMP.Writer.Charsets.ShiftJIS, TKMP.Writer.ContentTransferEncodings.QuotedPrintable); }
public System.IO.Stream GetBodyStream() { return _TextPart.GetBodyStream(); } public TKMP.Writer.Header.HeaderCollection Headers { get { //ヘッダ一覧のコピーを作成します TKMP.Writer.Header.HeaderCollection hc = new TKMP.Writer.Header.HeaderCollection(); foreach (TKMP.Writer.Header.HeaderString hs in _TextPart.Headers) { hc.Add(hs.Name, hs.Data); } //ここで必要な情報を書き換えます hc.Add("Content-Type", "text/html; charset=Shift-JIS");//★HTML指定★ //新しく作成した一覧を公開します return hc; } }
}
/// <summary> 送信 </summary> private void send() {
MailWriter mail = new TKMP.Writer.MailWriter();
//本文のクラスを作成します //★テキストとHTMLを含める。★ IPart part = new TKMP.Writer.MultiPart( new TextPart("テキスト本文"), new HtmlPart("HTML本文<br>HTML本文"));
しかし、メール本文が以下のようになりました。。 ------------------------------------------------------------ This is a multi-part message in MIME format. ------=_NextPart_******************* Content-Type: text/html; charset=Shift-JIS Content-Transfer-Encoding: base64