c# 在默认的另一个日历中添加 session 请求

标签 c# outlook calendar

我想向某人发送 session 请求(列表中的邮件)。 session 不能在默认日历中。它需要在 (fullpathCalendar)"\\Methode\Calendar" 中。

这是我目前所拥有的:

Outlook.Application OutlookApp = new Outlook.Application();
// Change the session or calendar ? 
 Outlook.AppointmentItem appt = (Outlook.AppointmentItem)
       OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);

appt.Subject = "";
appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
appt.Location = "";
appt.Start = DateTime.Now.AddHours(2);
appt.End = DateTime.Now.AddHours(3);
appt.AllDayEvent = false;
appt.Body = "sdfsdfsdfdsfsfdsfdsfsfsfdsfsfsdfsd";

如何将约会分配给该日历?

最佳答案

对于想要相同的人:

        string sendText = "";
        string subject = "";
        string location = "";
        string emails = {"dsqdsqdqsd@dsqdqd.com", "sdqdqdqd@dqsd.com"};
        Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
        Outlook.AppointmentItem appt = (Outlook.AppointmentItem)app.CreateItem(Outlook.OlItemType.olAppointmentItem);

        appt.Subject = subject;
        appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
        appt.Location = location;
        appt.Start = DateTime.Now.AddHours(1);
        appt.End = DateTime.Now.AddHours(3);
        appt.AllDayEvent = false;
        appt.Body = sendText;
        appt.ResponseRequested = false;

        foreach (string email in emails)
        {
            Outlook.Recipient recipRequired = appt.Recipients.Add(email);
            recipRequired.Type = (int)Outlook.OlMeetingRecipientType.olRequired;
        }

        appt.Recipients.ResolveAll();
        appt.Display(true);

        try
        {
            Outlook.MAPIFolder calendar = Data.OutlookHelper.AdxCalendar.getCallendar(app, @"\\Fichier de données Outlook\Calendrier\Methode");
            appt.Move(calendar);
        }
        catch
        {
            Dialogs.Alert alert = new Dialogs.Alert("Erreur", "Le rendez-vous est introuvable, vous l'avez peut-être supprimer.");
            alert.ShowDialog();
        }

还有我的 Data.OutlookHelper.AdxCalendar:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace Data.OutlookHelper
{
    public class AdxCalendar
    {
        public static Outlook.MAPIFolder getCallendar(Outlook.Application OutlookApp, string path)
        {
            Outlook.MAPIFolder calendar = null;
            foreach (Outlook.Store store in OutlookApp.Session.Stores)
            {
                if (store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).FullFolderPath.Equals(path))
                {
                    calendar = store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
                    break;
                }
                foreach (Outlook.MAPIFolder folder in store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Folders)
                {
                    if (folder.FullFolderPath.Equals(path))
                    {
                        calendar = folder;
                        break;
                    }
                }
                if (calendar != null)
                    break;
            }
            if (calendar == null)
            {
                return null;
            }
            return calendar;
        }
    }
}

关于c# 在默认的另一个日历中添加 session 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37569042/

相关文章:

java - 来自字符串 "1/12/2014"的 GregorianCalendar

calendar - GTK 下拉日历小部件?

c# - ASP.NET Core .css 扩展转到 Controller

email - 如何将参数传递给 .msg 文件?

html - 响应式 HTML 电子邮件 - Outlook 的 3 列布局间距

java - 在特定日期后的下周一获得第一个?

C# - 如何在多显示器上下文中获得真实的屏幕分辨率?

c# - 在 MVVM 中,在 View 的代码后面访问 ViewModel 是否可以接受?

c# - 如何在 Asp.Net Core 中自定义开发者异常页面?

html - outlook 在电子邮件签名中显示 css 代码