public void Test1() { abc: try { //emailProcessor.DeleteCalendarItem( content ); AppointmentItem newAppointment = (AppointmentItem)emailProcessor.CreateCalendarItem(content); if (newAppointment != null) { newAppointment.Display(); //newAppointment.Save(); } //Assert.Pass(); // } catch (System.Exception ex) { //TestContext.Out.WriteLine( ex.Message ); //TestContext.Out.WriteLine( ex.StackTrace ); } //TestContext.Error.WriteLine( "f**k " ); //TestContext.WriteLine( " off" ); // //goto abc; }
public byte[] Build(DateTime startTime, int duration, string roomName, string roomEmail, out string ext) { appt = olApp.CreateItem(OlItemType.olAppointmentItem); appt.MeetingStatus = OlMeetingStatus.olMeeting; appt.Subject = "<subject goes here>"; appt.Start = startTime; appt.Duration = duration; //appt.Location = "CN BJS (ARCA-1F, SE) Meeting Room Mencius [14] WB,TC,P"; //appt.Recipients.Add(room_email); appt.ReminderSet = true; appt.Display(true); appt.Resources = roomEmail; var tempFile = Path.GetTempFileName(); appt.SaveAs(tempFile); ext = "msg"; return File.ReadAllBytes(tempFile); }
public static void CreateEventOutlook(BookMeetingRoomForm data) { try { Application app = null; app = new Application(); AppointmentItem appt = app.CreateItem(OlItemType.olAppointmentItem) as AppointmentItem; appt.Subject = "Notice: book a meeting room"; appt.AllDayEvent = false; appt.Start = DateTime.Parse(data.StartDate.ToShortDateString() + " " + data.StartTime); //appt.End = DateTime.Parse(data.FinalDate.ToShortDateString() + " " + data.FinalTime); appt.Importance = OlImportance.olImportanceHigh; appt.Location = "Sala Pozuelo"; appt.Body = "Room type: " + data.TypeRoom.Value.ToString() + "Number of people: + " + data.Attendant.ToString(); appt.Display(false); } catch (System.Exception ex) { } }
private void btnMetting_Click(object sender, RibbonControlEventArgs e) { AppointmentItem item = helper.CreateMetting(); item.Display(); }
public void Meeting(IRibbonControl control, string subject, OlImportance importance) { try { string[] idParts = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries); Application outlookApp = new ApplicationClass(); AppointmentItem newMeeting = (AppointmentItem)outlookApp.CreateItem(OlItemType.olAppointmentItem); newMeeting.MeetingStatus = OlMeetingStatus.olMeeting; // Get the recipients string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id); if (!string.IsNullOrEmpty(recipients[0])) { foreach (Recipient recipRequired in recipients[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s))) { recipRequired.Type = (int)OlMeetingRecipientType.olRequired; } } if (!string.IsNullOrEmpty(recipients[1])) { foreach (Recipient recipOptional in recipients[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s))) { recipOptional.Type = (int)OlMeetingRecipientType.olOptional; } } newMeeting.Subject = subject; newMeeting.Importance = importance; string from = StaticHelper.GetApplicationSetting("MasterEmailAccount"); if (string.IsNullOrEmpty(from)) { from = StaticHelper.GetFromAccount(idParts[0]); } if (!string.IsNullOrEmpty(from)) { // Retrieve the account that has the specific SMTP address. Account account = GetAccountForEmailAddress(outlookApp, from); if (account != null) { // Use this account to send the e-mail. newMeeting.SendUsingAccount = account; } } if (control.Context is Inspector) { Inspector inspector = (Inspector)control.Context; if (inspector.CurrentItem is AppointmentItem) { AppointmentItem m = inspector.CurrentItem as AppointmentItem; // Get the recipients string[] recipients2 = StaticHelper.GetRecipients(idParts[0], control.Id); if (!string.IsNullOrEmpty(recipients2[0])) { foreach (Recipient recipRequired in recipients2[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s))) { recipRequired.Type = (int)OlMeetingRecipientType.olRequired; } } if (!string.IsNullOrEmpty(recipients2[1])) { foreach (Recipient recipOptional in recipients2[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s))) { recipOptional.Type = (int)OlMeetingRecipientType.olOptional; } } if (string.IsNullOrEmpty(m.Subject)) { m.Subject = newMeeting.Subject; } else { string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]); if (!string.IsNullOrEmpty(standardSuffix)) { newMeeting.Subject = newMeeting.Subject.Replace(standardSuffix, string.Empty); } m.Subject = newMeeting.Subject + m.Subject; } if (!string.IsNullOrEmpty(from)) { // Retrieve the account that has the specific SMTP address. Account account = GetAccountForEmailAddress(outlookApp, from); if (account != null) { // Use this account to send the e-mail. m.SendUsingAccount = account; } } } } else { newMeeting.Display(); } } catch (System.Exception ex) { StaticHelper.LogMessage(MessageType.Error, ex.ToString()); throw; } }
bool testing = false;//false true public override object CreateCalendarItem(string content) { ReservationParser reservationParser = new ReservationParser(content); /* * ConEx.Log(reservationParser.Reservation); * ConEx.Log(reservationParser.Location); * ConEx.Log(reservationParser.ActivityDateStart); * ConEx.Log(reservationParser.ActivityDateEnd); */ ConEx.Log("CreateCalendarItem: reservationsNumber={0}", reservationParser.Reservation); Items appts = GetAppointmentsByReservationNumber(reservationParser.Reservation); ConEx.Log("is this already present? " + ((appts != null) && (appts.Count > 0))); if (!testing) { if ((appts != null) && (appts.Count > 0)) { return(null); } } //string footer = "An email address was not found"; string footer = "<div><div><div>" + "N/A" + "</div></div></div>"; if (reservationParser.PrincipalPlayer != null) { footer = "<div><div><div>" + reservationParser.PrincipalPlayer.TrimEnd('\r').Trim() + "</div></div></div>"; } string categoryStr = tennisCat1; if (reservationParser.PrincipalPlayer.Contains("greenflashtennis")) { categoryStr = tennisCat2; } else if (reservationParser.PrincipalPlayer.Contains("gslockwood")) { categoryStr = tennisCat3; } AppointmentItem newAppointment = (AppointmentItem)app.CreateItem(OlItemType.olAppointmentItem); newAppointment.Start = reservationParser.ActivityDateStart; newAppointment.End = reservationParser.ActivityDateEnd; string body = reservationParser.Body + footer; newAppointment.Subject = string.Format("{0} #{1} ({2} minutes)", reservationParser.Location, reservationParser.Reservation, newAppointment.Duration); ItemProperty MeetingNameProperty = newAppointment.ItemProperties.Add(ReservationUserPropertyTitle, OlUserPropertyType.olText, true); MeetingNameProperty.Value = ReservationUserPropertyValue + reservationParser.Reservation; ConEx.Log("MeetingNameProperty.Value ={0}", MeetingNameProperty.Value); newAppointment.Categories = categoryStr; body += "<div>"; ////[SpoteryReservation]='Reservation: #1364009' //body += "<strong>["+ ReservationUserPropertyTitle + "]='" + MeetingNameProperty.Value + "'</strong>"; body += "Seachable"; body += "</div>"; HTML2RTFConverter html2RTFConverter = new HTML2RTFConverter(); string newTemp = html2RTFConverter.Convert(body); newAppointment.RTFBody = Encoding.ASCII.GetBytes(newTemp); if (testing) { newAppointment.Display(true); } else { newAppointment.Save(); } appts = GetAppointmentsByReservationNumber(reservationParser.Reservation); ConEx.Log("after save is this Now present? " + ((appts != null) && (appts.Count > 0))); return(newAppointment); // }