我想向我的電子郵件正文添加一些文本。但我不斷收到此錯誤:使用Outlook插件將文本添加到電子郵件C#2010
Error 1 'EmailHelper.EmailHelperRibbon' does not contain a definition for 'Application' and no extension method 'Application' accepting a first argument of type 'EmailHelper.EmailHelperRibbon' could be found (are you missing a using directive or an assembly reference?)
我的代碼如下所示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Tools.Ribbon;
using System.Windows.Forms;
namespace EmailHelper
{
public partial class EmailHelperRibbon
{
private void EmailHelperRibbon_Load(object sender, RibbonUIEventArgs e)
{
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
System.Windows.Forms.MessageBox.Show("Your Ribbon Works!");
Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem)
this.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
{
mailItem.Subject = "This text was added by using code";
mailItem.Body = "This text was added by using code";
}
}
}
}
讓我過去的錯誤,但它不會將文本添加到電子郵件的主題或正文。 – PriceCheaperton