从C#程序发送Outlook约会时如何避免Outlook安全警报

时间:2013-02-14 19:21:26

标签: c#


我写了一个函数,以便通过microsoft outlook发送预约。该方法有效,但在发送约会之前,会弹出Outlook安全警报并询问是否允许/拒绝访问。 这是我的代码:

public static void SendAppointment()
    {            
        Outlook.Application oApp = new Outlook.Application();            
        Outlook.AppointmentItem oAppointment = oApp.CreateItem(Outlook.OlItemType.olAppointmentItem);

        oAppointment.Subject = "subject";
        oAppointment.Body = "Body";
        oAppointment.Location = "some location";
        oAppointment.Start = DateTime.Now;
        oAppointment.End = DateTime.Now.AddDays(1);
        oAppointment.Importance = Outlook.OlImportance.olImportanceNormal;            
        oAppointment.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;

        Outlook.Recipient oRecip = oAppointment.Recipients.Add("sample@gmail.com");
        oRecip.Resolve(); // Not sure if this line is necessary

        oAppointment.Send();
    }

我看到某个地方要修复它不是为了建立新的应用程序而是为了获得现有的使用这一行:

Outlook.MailItem tempItem = Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);

但是我找不到Globals类所在的汇编。

0 个答案:

没有答案