public static CreateAttachmentResponse CreateAttachment(CreateAttachmentRequest request) { CreateAttachmentJsonRequest createAttachmentJsonRequest = new CreateAttachmentJsonRequest(); createAttachmentJsonRequest.Body = request; OWAService owaservice = new OWAService(); IAsyncResult asyncResult = owaservice.BeginCreateAttachment(createAttachmentJsonRequest, null, null); asyncResult.AsyncWaitHandle.WaitOne(); return(owaservice.EndCreateAttachment(asyncResult).Body); }
private static CreateAttachmentJsonRequest GetCreateAttachmentBody(FileInformation[] files) { var body = new CreateAttachmentJsonRequest() { __type = "CreateAttachmentJsonRequest:#Exchange", Header = new OwaAttachmentServer.Request.Header { __type = "JsonRequestHeaders:#Exchange", RequestServerVersion = "Exchange2013", TimeZoneContext = new Timezonecontext { __type = "TimeZoneContext:#Exchange", TimeZoneDefinition = new Timezonedefinition { __type = "TimeZoneDefinitionType:#Exchange", Id = "UTC" } } } }; var attachments = files.Select(p => new Request.Attachment { __type = "FileAttachment:#Exchange", Content = Convert.ToBase64String(p.Content), ContentType = "", IsContactPhoto = false, IsInline = false, Name = p.Name, Size = p.Content.Length }).ToArray(); body.Body = new Request.Body { __type = "CreateAttachmentRequest:#Exchange", ParentItemId = new Parentitemid { __type = "ItemId:#Exchange", Id = Message.Id, ChangeKey = ExchangeServiceProvider.Message.ChangeKey }, Attachments = attachments, RequireImageType = false, IncludeContentIdInResponse = false, ClientSupportsIrm = true, CancellationId = null }; return(body); }