2016-06-01 5 views
2

誰かに会議出席依頼を送信したいです(リスト内のメール)。 会議をデフォルトカレンダーにすることはできません。それは(fullpathCalendar)"\\Methode\Calendar"にある必要があります。c#デフォルトの別のカレンダーに会議出席依頼を追加します。

これは私がこれまで持っているものです。

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"; 

どのように私はそのカレンダーに予定を割り当てることができますか?

+0

は( "パスの\ calendarname")するvar暦= OutlookApp.GetFolderPath 'のようなものだろう' 'appt.Move(カレンダー)'? – stuartd

+0

なぜ私はそれを見たnerver?それは完全に動作します。ありがとうございます@stuartd – Monstreur

+0

招待された人に会議を受け入れる方法を知っていますか? – Monstreur

答えて

0

誰かが同じことをしたい場合:

 string sendText = ""; 
     string subject = ""; 
     string location = ""; 
     string emails = {"[email protected]", "[email protected]"}; 
     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; 
     } 
    } 
} 
関連する問題