public static void ProcessAttachment(IStoreSession session, string ewsAttachmentId, IExchangePrincipal exchangePrincipal, PropertyOpenMode openMode, WacUtilities.AttachmentProcessor attachmentProcessor) { IdConverterDependencies converterDependencies = new IdConverterDependencies.FromRawData(false, false, null, null, exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), session as MailboxSession, session as MailboxSession, session as PublicFolderSession); using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(ewsAttachmentId, converterDependencies)) { bool flag = WacUtilities.IsIrmRestricted(attachmentRetriever.RootItem); if (openMode == PropertyOpenMode.Modify) { attachmentRetriever.RootItem.OpenAsReadWrite(); } StreamAttachment streamAttachment = attachmentRetriever.Attachment as StreamAttachment; if (streamAttachment == null) { attachmentProcessor(exchangePrincipal, attachmentRetriever.Attachment, null, flag); } else { using (Stream contentStream = streamAttachment.GetContentStream(openMode)) { bool flag2 = WacUtilities.IsContentProtected(attachmentRetriever.Attachment.FileName, contentStream); attachmentProcessor(exchangePrincipal, streamAttachment, contentStream, flag || flag2); if (openMode == PropertyOpenMode.Modify) { attachmentRetriever.RootItem.Save(SaveMode.NoConflictResolution); } } } } }
private static bool MessageIsDraft(WacRequest wacRequest) { ADSessionSettings adsessionSettings; ExchangePrincipal exchangePrincipal = WacUtilities.GetExchangePrincipal(wacRequest, out adsessionSettings, wacRequest.WacFileRep.IsArchive); CultureInfo cultureInfo = CultureInfo.GetCultureInfo(wacRequest.CultureName); if (exchangePrincipal.RecipientTypeDetails == RecipientTypeDetails.PublicFolder) { return(false); } bool result; using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(exchangePrincipal, cultureInfo, "Client=OWA;Action=WAC")) { IdConverterDependencies converterDependencies = new IdConverterDependencies.FromRawData(false, false, null, null, wacRequest.MailboxSmtpAddress.ToString(), null, mailboxSession, null); using (AttachmentHandler.IAttachmentRetriever attachmentRetriever = AttachmentRetriever.CreateInstance(wacRequest.EwsAttachmentId, converterDependencies)) { Item rootItem = attachmentRetriever.RootItem; Attachment attachment = attachmentRetriever.Attachment; string text; string text2; result = WacUtilities.ItemIsMessageDraft(rootItem, attachment, out text, out text2); } } return(result); }