Тема: Appointment
Показать сообщение отдельно
Старый 01.07.2016, 15:28   #10  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Насколько я понял, то нет возможности создать html-таблицу в appointment, чтоб она нормально рендерилась в Outlook.

Что имею на сейчас:
X++:
   public class AppointmentCreator
    {
        private IOrganizationService _service { get; set; }
        private Guid _appointmentId = Guid.Empty;
        private Guid _templateId = new Guid("5f835b71-763f-e611-80de-005056883160");
        private Guid _userId = new Guid("db4e2fd9-d727-e611-80de-005056883160");
        public AppointmentCreator(IOrganizationService service)
        {
            _service = service;
        }

        public void Create()
        {
             Entity[] activityParty = new Entity[]
                {
                                new Entity("activityparty")
                            {
                                Attributes =
                                      {
                                                    { "partyid",  new EntityReference("systemuser", _userId) }
                                      }
                              }
                };

            // Create the appointment instance.
            Entity appointment = new Entity("appointment");
            appointment["subject"] = "Test Appointment";
            appointment["description"] = HtmlHelper.htmlTable;//mailTemplate.GetAttributeValue<string>("body");
            appointment["scheduledstart"] = DateTime.Now.AddHours(1);
            appointment["scheduledend"] = DateTime.Now.AddHours(2);
            appointment["location"] = "Office";
            appointment["requiredattendees"] = activityParty;
            appointment["organizer"] = activityParty;

            // Use the Book request message.
            BookRequest book = new BookRequest
            {
                Target = appointment
            };
            BookResponse booked = (BookResponse)_service.Execute(book);
            _appointmentId = booked.ValidationResult.ActivityId;

            // Verify that the appointment has been scheduled.
            if (_appointmentId != Guid.Empty)
            {
                Console.WriteLine("Succesfully booked {0}.", appointment.GetAttributeValue<string>("subject"));
                Console.ReadKey();
            }
        }
    }
И простенький класс

X++:
   public static class HtmlHelper
    {
        public static string htmlTable = @"<table border = '1' >
            < caption > Таблица размеров обуви</caption>
            <tr><th>Россия</th><th>Великобритания</th>
            <th>Европа</th><th>Длина ступни, см</th>
            </tr><tr><td>34,5</td><td>3,5</td><td>36</td><td>23</td></tr></table>";

        public static string htmlH1 = "<h1>My test body</h1>";
    }