如何创建约会并将其发送到 Microsoft Outlook 日历?

发布于 2024-08-16 02:34:12 字数 1226 浏览 4 评论 0原文

我正在尝试使用以下代码在另一个人的 Microsoft Outlook (2003) 日历中创建约会。运行此程序时,约会将保存在我的日历中。但不会发送给收件人。

try
{
    Microsoft.Office.Interop.Outlook.Application app = null;
    Microsoft.Office.Interop.Outlook.AppointmentItem appt = null;

    app = new Microsoft.Office.Interop.Outlook.Application();

    appt = (Microsoft.Office.Interop.Outlook.AppointmentItem)app
        .CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
    appt.Subject = "Meeting ";
    appt.Body = "Test Appointment body";
    appt.Location = "TBD";
    appt.Start = Convert.ToDateTime("12/23/2009 05:00:00 PM");
    appt.Recipients.Add("[email protected]");
    appt.End = Convert.ToDateTime("12/23/2009 6:00:00 PM");
    appt.ReminderSet = true;
    appt.ReminderMinutesBeforeStart = 15;
    appt.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
    appt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
    appt.Save();
    appt.Send();
}
catch (COMException ex)
{
    Response.Write(ex.ToString());
}

我错过了什么吗?任何人都可以帮我解决这个问题吗?

I am trying to create an appointment in the Microsoft Outlook (2003) calender of another person using the below code.While running this program, The Appointment is getting saved in my calender.But not being sent to the recipient.

try
{
    Microsoft.Office.Interop.Outlook.Application app = null;
    Microsoft.Office.Interop.Outlook.AppointmentItem appt = null;

    app = new Microsoft.Office.Interop.Outlook.Application();

    appt = (Microsoft.Office.Interop.Outlook.AppointmentItem)app
        .CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
    appt.Subject = "Meeting ";
    appt.Body = "Test Appointment body";
    appt.Location = "TBD";
    appt.Start = Convert.ToDateTime("12/23/2009 05:00:00 PM");
    appt.Recipients.Add("[email protected]");
    appt.End = Convert.ToDateTime("12/23/2009 6:00:00 PM");
    appt.ReminderSet = true;
    appt.ReminderMinutesBeforeStart = 15;
    appt.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
    appt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
    appt.Save();
    appt.Send();
}
catch (COMException ex)
{
    Response.Write(ex.ToString());
}

Am i missing anything? Can any one help me out to solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

山田美奈子 2024-08-23 02:34:12

预约后:

Outlook.MailItem mailItem = appt.ForwardAsVcal();
mailItem.To = "recipient's email address";
mailItem.Send();

After you have the appointment:

Outlook.MailItem mailItem = appt.ForwardAsVcal();
mailItem.To = "recipient's email address";
mailItem.Send();
花桑 2024-08-23 02:34:12

尝试添加:

appt.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;

默认状态是一个约会,我不确定是否已发送。

Try adding:

appt.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;

Default status is an appointment which I'm not sure is being sent.

倾城花音 2024-08-23 02:34:12

以下是我解决此问题的方法:

我放置(如 Sonny Boy 的帖子):

Outlook.MailItem mailItem = appt.ForwardAsVcal();
mailItem.To = "[email protected]";
mailItem.Send();

但我还必须创建一个 web.config 文件,并设置授权访问以避免任何 COMException :

<system.web>
  <authorization>
    <deny users="?"/>
  </authorization>
</system.web>

Here is how I fixed this issue :

I put (like Sonny Boy's post) :

Outlook.MailItem mailItem = appt.ForwardAsVcal();
mailItem.To = "[email protected]";
mailItem.Send();

But I also had to create a web.config file, and to set up the authorization access to avoid any COMException :

<system.web>
  <authorization>
    <deny users="?"/>
  </authorization>
</system.web>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文