Пример #1
0
        public void simple_calendar_test()
        {
            // Arrange
            CalendarEventRequest cEvent = new CalendarEventRequest();
            cEvent.PRODID = "-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN";
            cEvent.DateStart = DateTime.Parse("7/26/2014 7:30AM").ToString("yyyyMMdd\\THHmmss");
            cEvent.DateEnd = DateTime.Parse("7/26/2014 11:30AM").ToString("yyyyMMdd\\THHmmss");
            cEvent.Description = "Important Reminders \n•	Please arrive at the course at least 30 minutes prior to Shotgun start time.\n•	CASH ONLY for payment of green fees and guest fees!!!\n•	Slow play is not permitted. Please be courteous to all golfers and keep on pace.\nIf you have any questions please contact either:\n•	[email protected] - 760-777-7090";
            cEvent.Location = "Classic Club Golf Course - Palm Desert";
            cEvent.Priority = 2;
            cEvent.Subject = "Classic Club Golf Course";
            cEvent.UID = "*****@*****.**";
            cEvent.Version = "1.0";
            cEvent.FileName = "Classic Club Golf Course";

            ICalendar simple = new SimpleCalendar(cEvent);

            Calendar calendar = new Calendar(simple);

            // Act
            calendar.Save();

            // Assert
            //Console.WriteLine(actual);
        }
Пример #2
0
        public ActionResult Create(MessageModel model)
        {
            string filePath = Server.MapPath("~/ics/Demo Message.ics");

            // Store the file path in the model that will be passed to the Mailer object.
            model.FileName = filePath;

            // First thing to do is populate the CalendarEventRequest object.
            CalendarEventRequest cEvent = new CalendarEventRequest();
            cEvent.PRODID = "-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN";
            cEvent.Version = "2.0";

            cEvent.DateStart = model.StartDate.ToString("yyyyMMdd\\THHmmss");
            cEvent.DateEnd = model.EndDate.ToString("yyyyMMdd\\THHmmss");
            cEvent.Description = model.Message;
            cEvent.Location = model.Location;
            cEvent.Priority = 3;
            cEvent.Subject = model.Subject;
            cEvent.FileName = filePath;

            try
            {
                // Now create an instance of the calendar object you want to use.  In this case
                // I just want to send a basic simple calendar message.
                ICalendar simple = new SimpleCalendar(cEvent);

                // Now create the Calendar instance and pass it the ICalendar interface implementation.
                Calendar calendar = new Calendar(simple);

                // This will save the ics file to disk where the Mailer object can retrieve it.
                calendar.Save();

                /******* Begin Mailer Functions *********/
                // Don't forget to update your web.config/smtp settings.
                Mailer.Success(model).Send();
            }
            catch (Exception ex)
            {
                string msg = string.Empty;

                if (ex.InnerException != null)
                {
                    msg = ex.InnerException.Message + " - ";
                }

                msg += ex.Message;

                ModelState.AddModelError("", msg);
                return RedirectToAction("Create");
            }

            return View("MessageSuccess");
        }