【问题标题】:Outlook 2007 - How to insert RTF text into an AppointmentItemOutlook 2007 - 如何将 RTF 文本插入 AppointmentItem
【发布时间】:2012-05-02 02:45:50
【问题描述】:

我正在使用 Outlook 2007,我需要将 RTF 文本插入到 AppointmentItem。我发现一些帖子声称您可以使用这样那样的方式做到这一点,但没有显示如何做到这一点的实际代码。到目前为止我找到的最好的来源是Here

我跟着它,但最后没有任何东西被插入到约会项目中。

以下是我所拥有的:

Word.Document wd = AppointmentItem.GetInspector.WordEditor as Word.Document;

// *Assume that I have all the RTF text that I want to copy set up and ready in the clipboard and is ready to be inserted(copied) into the Appointment Item.

//This doesnt seem to work
wd.Content.Select();
wd.Content.Paste();

//This also doesnt seem to work
(AppointmentItem.GetInspector.WordEditor as Word.Document).Content.Select();
(AppointmentItem.GetInspector.WordEditor as Word.Document).Content.Paste();

因此,根据我所阅读和看到的内容,这就是您假设将 RTF 插入约会项目的方式,但我仍然无法将任何内容放入 AppointmentItem

现在,如果我看一下这个变量的话:

(AppointmentItem.GetInspector.WordEditor as Word.Document).Content.Text;

但如果我查看AppointmentItem.Text,它仍然没有改变。

现在没有AppointmentItem.paste()AppointmentItem.text.paste() 的函数,并且您无权访问约会项目中的RTF 变量。

那么谁能告诉我我错过了什么?如何粘贴到 AppointmentItem 或实际将 RTF 文本放入 AppointmentItem

谢谢。

【问题讨论】:

    标签: com outlook outlook-2007 outlook-2010


    【解决方案1】:

    对于任何试图通过 Office 2010、2013 解决此问题的人:

    string sRtfBody = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Century Gothic;}}\viewkind4\uc1\pard\f0\fs20 This course will help you appreciate the beauty of numbers in some ways that you may have never considered.\par}";
    Outlook.AppointmentItem aiMeeting = (Outlook.AppointmentItem)this._Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
    aiMeeting.RTFBody = Encoding.ASCII.GetBytes(sRtfBody);
    

    【讨论】:

      【解决方案2】:

      问题是您没有指定复制和粘贴的选择。复制和粘贴的工作方式与用户进行复制和粘贴完全一样,您必须先选择所需的范围。

      试试

      wd.Sections[1].Range.Copy();
      document.Range(0, 0).PasteAndFormat(Word.WdRecoveryType.wdPasteDefault);
      

      Tom_Xu MSFT 在名为“Load a .doc file content in Outlook.MailItem”的线程中写了一篇与此类似的好文章

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-05-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多