本文整理汇总了C#中ExchangeService.CreateItems方法的典型用法代码示例。如果您正苦于以下问题:C# ExchangeService.CreateItems方法的具体用法?C# ExchangeService.CreateItems怎么用?C# ExchangeService.CreateItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExchangeService
的用法示例。
在下文中一共展示了ExchangeService.CreateItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCalendarEvent
public bool CreateCalendarEvent(ExchangeService service,Appointment objAppointment,string[] rqdAttendeelist,string[] optionalAttendeelist)
{
try
{
ItemView itemView = new ItemView(100);
itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly);
List<Appointment> ToCreate = new List<Appointment>();
Appointment appointment = new Appointment(service);
appointment.Subject = objAppointment.Subject;// "Calendar Request from Console App";
appointment.Location = objAppointment.Location;// "Office365";
appointment.Start = TimeZoneInfo.ConvertTimeToUtc(objAppointment.Start, TimeZoneInfo.Local);
appointment.End = TimeZoneInfo.ConvertTimeToUtc(objAppointment.End, TimeZoneInfo.Local);// objAppointment.End;
appointment.Body = objAppointment.Body;
appointment.IsReminderSet = objAppointment.IsReminderSet;
appointment.IsResponseRequested = false;
foreach(string req in rqdAttendeelist)
{
appointment.RequiredAttendees.Add(req);
}
foreach (string opt in optionalAttendeelist)
{
appointment.OptionalAttendees.Add(opt);
}
ToCreate.Add(appointment);
ServiceResponseCollection<ServiceResponse> CreateResponse = service.CreateItems(ToCreate, WellKnownFolderName.Calendar, MessageDisposition.SaveOnly, SendInvitationsMode.SendOnlyToAll);
return true;
}
catch
{
return false;
}
finally
{
service = null;
}
}
示例2: AddHolidays
/**
* Function Add the Holidays
**/
static void AddHolidays(ExchangeService service, List<string[]> holidays, List<string> mailboxes)
{
// Log file
string datetimeString = DateTime.Now.ToString("MMddyyyy");
string logfile = "../../logs/" + datetimeString + "_add_holiday_log.txt";
//Initiate Error List
List<string> mbs = new List<string>();
using (System.IO.StreamWriter log = new System.IO.StreamWriter(@logfile, true))
{
// Loop through each email address in the passed in mailboxes List
foreach (string mailbox in mailboxes)
{
// Impersonate that User
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, mailbox);
Console.WriteLine("Attempting to Add Holidays to: " + mailbox);
List<Appointment> uga_holidays = new List<Appointment>();
// Loop through all the holidays
foreach (string[] holiday in holidays)
{
//Create a new appointment
Appointment appointment = new Appointment(service);
// Set details
appointment.Subject = holiday[0];
appointment.Start = DateTime.Parse(holiday[1]);
appointment.End = appointment.Start.AddDays(1);
appointment.IsAllDayEvent = true;
StringList categories = new Microsoft.Exchange.WebServices.Data.StringList();
categories.Add("Holiday");
appointment.Categories = categories;
appointment.IsReminderSet = false;
uga_holidays.Add(appointment);
}
// Save and Send
try
{
service.CreateItems(uga_holidays, WellKnownFolderName.Calendar, MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone);
Console.WriteLine("Added Holiday Successfully to: " + mailbox);
DateTime now = DateTime.Now;
log.WriteLine(now + " - Added holidays succesfully to Mailbox: " + mailbox);
}
catch (Exception ex)
{
Console.WriteLine("Error During Initial Add - Mailbox: " + mailbox + "; Exception thrown: " + ex);
log.WriteLine("Error During Initial Add - Mailbox: " + mailbox + "; Exception thrown: " + ex);
mbs.Add(mailbox);
}
// Clear impersonation.
service.ImpersonatedUserId = null;
}
//Process Rerun List
if (mbs.Count > 0)
{
Console.WriteLine("Looping through re-run mailboxes.");
while (mbs.Count > 0)
{
// Current mailbox
string mb = mbs.ElementAt(0);
Console.WriteLine("On Mailbox: " + mb);
// Take the mailbox out of the first element slot
log.WriteLine("Removing mailbox " + mb + " from beginning of mbs.");
mbs.RemoveAt(0);
mbs.TrimExcess();
try
{
// Reruns: Removes
// Run search
// Impersonate that User
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, mb);
// Search String
String category = "Holiday";
// Search Filter
SearchFilter.IsEqualTo filter = new SearchFilter.IsEqualTo(AppointmentSchema.Categories, category);
// Result Return Size, number of items
ItemView holidayView = new ItemView(100);
// Limit data to only necesary components
//.........这里部分代码省略.........