这可能是非常初学者的问题。我正在尝试创建我的第一个 Windows 窗体应用程序,并希望通过单击窗体上的按钮来创建 Outlook 电子邮件。
问题是有13个错误,主要是:
严重性代码 说明 项目文件行抑制状态错误 CS0246 找不到类型或命名空间名称“Outlook”(是否缺少 using 指令或程序集引用?) Offer machine v.0.0.1 C:\Users\PC\source \repos\Offer machine v.0.0.1\Offer machine v.0.0.1\Form1.cs 29 活动
我已经添加了对我的项目的引用:
这是代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Offer_machine_v._0._0._1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
try
{
List<string> lstAllRecipients = new List<string>();
//Below is hardcoded - can be replaced with db data
lstAllRecipients.Add("sanjeev.kumar@testmail.com");
lstAllRecipients.Add("chandan.kumarpanda@testmail.com");
Outlook.Application outlookApp = new Outlook.Application();
Outlook._MailItem oMailItem = (Outlook._MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
Outlook.Inspector oInspector = oMailItem.GetInspector;
// Thread.Sleep(10000);
// Recipient
Outlook.Recipients oRecips = (Outlook.Recipients)oMailItem.Recipients;
foreach (String recipient in lstAllRecipients)
{
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(recipient);
oRecip.Resolve();
}
}
}
四季花海
桃花长相依
相关分类