我想通过 Outlook
和 C#
发送 Mail
但是我的 Attachments
的位置有问题 . 我有以下代码:
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具有以下 Value :
{\ rtf1 \ ansi \ ansicpg1252 \ deff0 \ deflang1031 {\ fonttbl {\ f0 \ fnil \ fcharset0 Arial;}} {\ 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
显示在结尾?
1 回答
嗯,你做的一切都正确 . 每个值> 1都会将附件放在邮件末尾 . 在“hier ihre AB”之后放置它 . 看起来很愚蠢但很好......作为一个小解决方法,我也使用它,放置一些新的线条 . 尽可能将附件放在最后一句话之下 .
或者您将邮件编写为HTML类型 . 减少问题 .
编辑:
如您所见,该文件位于邮件的末尾 .
编辑二:
以下是使用附件行中的附件将您的电子邮件作为HTML发送的方法的示例: