我想通過Outlook
和C#
發送Mail
但我的Attachments
的位置存在問題。我有以下代碼:附件在RTF郵件中的位置
if (strBody.StartsWith(@"{\rtf"))
{
mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText;
mailItem.RTFBody = Encoding.UTF8.GetBytes(strBody);
mailItem.Attachments.Add(strAttachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, int.MaxValue, null);
}
else
{
mailItem.Body = strBody;
mailItem.Attachments.Add(strAttachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 1, null);
}
我strBody具有以下值:
{\ RTF1 \ ANSI \ ansicpg1252 \ deff0 \ deflang1031 {\ fonttbl {\ F0 \ fnil \ fcharset0宋體;}} {\ colortbl; \ red255 \ green0 \ blue128; \ red0 \ green128 \ blue255;} \ viewkind4 \ uc1 \ pard \ fs20 Sehr geehrte \ cf1 Damen \ cf0 und \ cf2 Herren \ cf0,\ par \ par hier ihre AB \ fs20 \ par }
但我的Mail
看起來像這樣:
我現在的問題是,
- 能否
Attachments
顯示爲當郵件沒有RTF格式像一個額外的行? - 如果不是1.,那麼我怎樣才能讓我的
Attachments
顯示在最後?
我看到了這個念頭了'HTML'爲好,但我的文本來自'RichTextBox',所以它在'RTF'中。有沒有將'RTF'轉換爲'HTML'的好方法? –
@ E-Nuff此文檔幫助了我很多:https://www.codeproject.com/kb/recipes/rtfconverter.aspx – Cataklysim
緊緊抓住你。最後一個問題是附件是不是可以在正文中顯示,但是像普通郵件一樣作爲額外的行被嵌入? –