/// <summary> /// create a draft message using pre-defined values /// </summary> /// <returns>json formatted draft message body</returns> public static string CreateDraftMessageJson() { // create message Message msg = new Message(); // set the subject and importance msg.subject = "json test message"; msg.importance = "Normal"; // create and populate the body object Body dftBody = new Body(); dftBody.contentType = "HTML"; dftBody.content = "The <b>new</b> cafeteria is open!"; msg.body = dftBody; // create an offset with the current time DateTimeOffset dto = new DateTimeOffset(); dto = DateTime.Now; // set the time values for the message msg.createdDateTime = dto; msg.lastModifiedDateTime = dto; // create and populate the recips object // first create a List of ToRecipient objects List<Recipient> recipList = new List<Recipient>(); // use the NewRecipient function to create an individual recip // and set the emailaddress info Recipient recip1 = NewRecipient("*****@*****.**", "Pavel Bansky"); Recipient recip2 = NewRecipient("*****@*****.**", "Mavel Bansky"); // add the recips to the list recipList.Add(recip1); recipList.Add(recip2); msg.toRecipients = recipList; // create attachments List<Attachment> msgAttachments = new List<Attachment>(); FileAttachment msgAttachment = new FileAttachment(); msgAttachment.oDataType = "#Microsoft.OutlookServices.FileAttachment"; msgAttachment.name = "menu.txt"; msgAttachment.contentBytes = "bWFjIGFuZCBjaGVlc2UgdG9kYXk="; msgAttachments.Add(msgAttachment); // add attachment to message msg.attachments = msgAttachments; return SerializeJson(msg); }
/// <summary> /// create a meeting with pre-defined values /// </summary> /// <returns>json formatted string body</returns> public static string CreateEventJson() { // create the event object Event evt = new Event(); evt.subject = "Discuss the Calendar REST API"; // create the body object Body body = new Body(); body.contentType = "HTML"; body.content = "I think it will meet our requirements!"; evt.body = body; // create an offset with the current time DateTimeOffset dto = new DateTimeOffset(); dto = DateTime.Now; // create the start time DateTimeTimeZone start = new DateTimeTimeZone(); start.dateTime = dto; start.timeZone = "Pacific Standard Time"; evt.start = start; // create the end time DateTimeTimeZone end = new DateTimeTimeZone(); end.dateTime = dto.AddMinutes(30); end.timeZone = "Pacific Standard Time"; evt.end = end; // set the other time values evt.createdDateTime = dto; evt.lastModifiedDateTime = dto; evt.originalStart = dto; evt.reminderMinutesBeforeStart = 15; // create the attendee list, attendee object and emailaddress object List<Attendee> attendeesList = new List<Attendee>(); Attendee attendee = new Attendee(); EmailAddress email = new EmailAddress(); // set values for email and attendee email.address = "*****@*****.**"; email.name = "Pavel Bansky"; attendee.emailAddress = email; attendee.type = "Required"; // add the attendee to the list and set the event object attendeesList.Add(attendee); evt.attendees = attendeesList; return SerializeJson(evt); }