0
'Dashboard.Email'沒有包含'Application'的定義,也沒有包含接受'Dashboard.Email'類型的第一個參數的擴展方法'Application'可以找到(您是否缺少使用指令或程序集引用?)錯誤:'MyProject.Email不包含'應用程序'的定義
我試過添加引用和使用語句無濟於事。我只是想在VS2010 .NET 4 Framework中創建一個簡單的郵件對象。
using System;
using System.Data;
using System.Windows;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Deployment.Application;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Outlook;
namespace Dashboard
{
public class Email
{
public void CreateEmailItem()
{
MailItem eMail = (MailItem)this.Application.CreateItem(OlItemType.olMailItem);
eMail.Subject = "This is the subject";
eMail.To = "[email protected]";
eMail.Body = "This is the body";
eMail.Importance = OlImportance.olImportanceLow;
((_MailItem)eMail).Send();
}
}
}
您可以參考的答案該鏈接 http://stackoverflow.com/questions/11242745/trying-to-programmatically-create-open-a-new-outlook-email – dmn