【发布时间】:2014-07-04 19:56:31
【问题描述】:
我有一个 winforms 应用程序,我正在尝试创建一个方法来创建和打开一个新的 Outlook 电子邮件。到目前为止我有
private void CreateOutlookEmail()
{
try
{
Outlook.MailItem mailItem = (Outlook.MailItem)
this.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
mailItem.To = "someone@example.com";
mailItem.Body = "This is the message.";
mailItem.Importance = Outlook.OlImportance.olImportanceLow;
mailItem.Display(false);
}
catch (Exception eX)
{
throw new Exception("cDocument: Error occurred trying to Create an Outlook Email"
+ Environment.NewLine + eX.Message);
}
}
但“CreateItem”引用带有错误消息下划线
"不包含 CreateItem 的定义"
我认为“CreateItem”是 MS Office 项目的标准方法,但不可否认,我确实在另一个网站上找到了上述代码并简单地复制了它。
请问我误会了什么?
【问题讨论】:
-
你把这个方法放在哪里? IE。对
this的引用是否位于 VSTO Outlook 插件项目中?我怀疑您需要创建一个新的 Outlook 插件项目,然后将此代码放入该项目中。