“Dashboard.Email”不包含“Application”的定义,并且找不到接受“Dashboard.Email”类型的第一个参数的扩展方法“Application”(您是否缺少 using 指令或程序集引用?)
我试过添加引用和使用语句无济于事。我只是想在 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 = "example@gmail.com";
eMail.Body = "This is the body";
eMail.Importance = OlImportance.olImportanceLow;
((_MailItem)eMail).Send();
}
}
}