コード例 #1
0
        protected override byte[] MessageSaveChanges(StorageFxProxyPool.MessageEntry entry)
        {
            CoreItem referencedObject = entry.WrappedObject.ReferenceCoreItem.ReferencedObject;

            if (entry.MimeStream != null || entry.CachedItemProperties.Count > 0)
            {
                using (Item item = new Item(referencedObject, true))
                {
                    if (entry.MimeStream != null)
                    {
                        InboundConversionOptions scopedInboundConversionOptions = MapiUtils.GetScopedInboundConversionOptions(this.destMailbox.StoreSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid));
                        using (entry.MimeStream)
                        {
                            ItemConversion.ConvertAnyMimeToItem(item, entry.MimeStream, scopedInboundConversionOptions);
                        }
                    }
                    foreach (ItemPropertiesBase itemPropertiesBase in entry.CachedItemProperties)
                    {
                        itemPropertiesBase.Apply((MailboxSession)this.destMailbox.StoreSession, item);
                    }
                }
            }
            if (entry.CachedPropValues.Count > 0)
            {
                this.SetProps(entry.WrappedObject.PropertyBag, entry.CachedPropValues.ToArray());
            }
            entry.WrappedObject.Save();
            referencedObject.PropertyBag.Load(StorageFxProxyPool.EntryIdPropDef);
            return(referencedObject.PropertyBag[StorageFxProxyPool.EntryIdPropDef[0]] as byte[]);
        }
コード例 #2
0
 internal static void CreateAttachment(IItem parentItem, Attachment16Data attachmentData)
 {
     AirSyncDiagnostics.TraceDebug <byte>(ExTraceGlobals.RequestsTracer, null, "CreateAttachment with AttachMethod:{0}", attachmentData.Method);
     if (attachmentData.Method == 1)
     {
         if (attachmentData.Content == null)
         {
             throw new ConversionException(string.Format(" Attachment content can not be null.", new object[0]));
         }
         IStreamAttachment streamAttachment = parentItem.IAttachmentCollection.CreateIAttachment(AttachmentType.Stream) as IStreamAttachment;
         AttachmentHelper.CopyCommonAttachmentProperties(streamAttachment, attachmentData);
         using (Stream contentStream = streamAttachment.GetContentStream())
         {
             contentStream.Write(attachmentData.Content, 0, attachmentData.Content.Length);
         }
         streamAttachment.Save();
     }
     else
     {
         if (attachmentData.Method != 5)
         {
             throw new ConversionException(string.Format("UnSupported Value '{0}' for Attachment Method. Only 1 & 5 is supported AttachemntType", attachmentData.Method));
         }
         ItemAttachment itemAttachment = parentItem.IAttachmentCollection.CreateIAttachment(AttachmentType.EmbeddedMessage) as ItemAttachment;
         AttachmentHelper.CopyCommonAttachmentProperties(itemAttachment, attachmentData);
         using (Stream stream = new MemoryStream(attachmentData.Content))
         {
             stream.Seek(0L, SeekOrigin.Begin);
             InboundConversionOptions inboundConversionOptions = AirSyncUtility.GetInboundConversionOptions();
             inboundConversionOptions.ClearCategories = false;
             try
             {
                 using (Item item = itemAttachment.GetItem())
                 {
                     ItemConversion.ConvertAnyMimeToItem(item, stream, inboundConversionOptions);
                     item.Save(SaveMode.NoConflictResolution);
                 }
             }
             catch (ExchangeDataException innerException)
             {
                 throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException, false);
             }
             catch (ConversionFailedException innerException2)
             {
                 throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException2, false);
             }
         }
         itemAttachment.Save();
     }
     AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.RequestsTracer, null, "AttachmentHelper:CreateAttachments:: AttachmentCreated successful. AttachmentCount:{0}", parentItem.IAttachmentCollection.Count);
 }
コード例 #3
0
        private void ImportMessageMime(MessageItem item)
        {
            this.ClearMessagePropertiesForMimeImport(item);
            InboundConversionOptions options = Utilities.CreateInboundConversionOptions(base.UserContext);

            using (MemoryStream memoryStream = new MemoryStream(Encoding.ASCII.GetBytes((string)base.GetParameter("MimeBlob"))))
            {
                ItemConversion.ConvertAnyMimeToItem(item, memoryStream, options);
            }
            if (Utilities.IsIrmDecrypted(item))
            {
                RightsManagedMessageItem rightsManagedMessageItem = (RightsManagedMessageItem)item;
                rightsManagedMessageItem.SetProtectedData(item.Body, item.AttachmentCollection);
                rightsManagedMessageItem.SetDefaultEnvelopeBody(null);
            }
            item.From   = null;
            item.Sender = null;
            base.UpdateComplianceAction(item);
        }
コード例 #4
0
        // Token: 0x0600003E RID: 62 RVA: 0x00004434 File Offset: 0x00002634
        private void AttachOriginalMessageToNotification(MessageItem initiationMessage, MessageItem notificationMessage, out string originalSenderDisplayname)
        {
            originalSenderDisplayname = string.Empty;
            if (string.IsNullOrEmpty(this.defaultAcceptedDomain))
            {
                ModeratedDLApplication.diag.TraceDebug((long)this.GetHashCode(), "Cannot attach original message to notification without domain for content conversion.");
                return;
            }
            AttachmentCollection attachmentCollection = initiationMessage.AttachmentCollection;

            foreach (AttachmentHandle handle in attachmentCollection)
            {
                using (Attachment attachment = attachmentCollection.Open(handle))
                {
                    if ("OriginalMessage".Equals(attachment.FileName, StringComparison.OrdinalIgnoreCase))
                    {
                        StreamAttachment streamAttachment = attachment as StreamAttachment;
                        if (streamAttachment != null)
                        {
                            using (Stream contentStream = streamAttachment.GetContentStream(PropertyOpenMode.ReadOnly))
                            {
                                using (ItemAttachment itemAttachment = (ItemAttachment)notificationMessage.AttachmentCollection.Create(AttachmentType.EmbeddedMessage))
                                {
                                    using (Item item = itemAttachment.GetItem())
                                    {
                                        InboundConversionOptions options = new InboundConversionOptions(this.defaultAcceptedDomain);
                                        ItemConversion.ConvertAnyMimeToItem(item, contentStream, options);
                                        item[MessageItemSchema.Flags] = MessageFlags.None;
                                        originalSenderDisplayname     = (item.TryGetProperty(MessageItemSchema.SenderDisplayName) as string);
                                        item.Save(SaveMode.NoConflictResolution);
                                        itemAttachment[AttachmentSchema.DisplayName] = initiationMessage.Subject;
                                        itemAttachment.Save();
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
コード例 #5
0
        private bool TryParkThisMessage(StoreDriverDeliveryEventArgsImpl args, MeetingSeriesMessageOrderingAgent.SeriesHeadersData headersData)
        {
            Guid networkMessageId = args.MailItemDeliver.MbxTransportMailItem.NetworkMessageId;

            this.AddUnparkedHeader(args.MailItem.Message.MimeDocument.RootPart.Headers, networkMessageId);
            bool   encapsulationSucceeded = true;
            string text;
            bool   encapsulationSucceeded2;

            using (EmailMessage emailMessage = ModerationHelper.EncapsulateOriginalMessage(args.MailItemDeliver.MbxTransportMailItem, new List <MailRecipient>
            {
                args.MailRecipient
            }, args.MailRecipient.Email.ToString(), args.MailRecipient.Email.ToString(), MeetingSeriesMessageOrderingAgent.tracer, delegate(Exception param0)
            {
                encapsulationSucceeded = false;
            }, out text))
            {
                if (encapsulationSucceeded)
                {
                    MailboxSession mailboxSession = args.MailboxSession;
                    using (ParkedMeetingMessage parkedMeetingMessage = ParkedMeetingMessage.Create(mailboxSession))
                    {
                        if (parkedMeetingMessage != null)
                        {
                            string internetMessageId = args.MailItemDeliver.MbxTransportMailItem.InternetMessageId;
                            ItemConversion.ConvertAnyMimeToItem(parkedMeetingMessage, emailMessage.MimeDocument, new InboundConversionOptions(args.ADRecipientCache));
                            parkedMeetingMessage.ParkedCorrelationId          = ParkedMeetingMessage.GetCorrelationId(headersData.SeriesId, headersData.SeriesSequenceNumber);
                            parkedMeetingMessage[StoreObjectSchema.ItemClass] = "IPM.Parked.MeetingMessage";
                            parkedMeetingMessage.CleanGlobalObjectId          = headersData.InstanceGoid;
                            parkedMeetingMessage.OriginalMessageId            = internetMessageId;
                            int retentionPeriod = MeetingSeriesMessageOrderingAgent.GetRetentionPeriod(args.MailboxOwner);
                            PolicyTagHelper.SetRetentionProperties(parkedMeetingMessage, ExDateTime.UtcNow.AddDays((double)retentionPeriod), retentionPeriod);
                            parkedMeetingMessage.Save(SaveMode.NoConflictResolution);
                        }
                    }
                }
                encapsulationSucceeded2 = encapsulationSucceeded;
            }
            return(encapsulationSucceeded2);
        }
コード例 #6
0
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            IContentProperty contentProperty = (IContentProperty)srcProperty;
            BodyType         nativeType      = contentProperty.GetNativeType();

            if (nativeType == BodyType.Mime && string.Equals(base.XsoItem.ClassName, "IPM.NOTE.MOBILE.MMS", StringComparison.OrdinalIgnoreCase))
            {
                Item itemOut = (Item)base.XsoItem;
                InboundConversionOptions inboundConversionOptions = AirSyncUtility.GetInboundConversionOptions();
                inboundConversionOptions.ClearCategories = false;
                try
                {
                    Stream body = ((IContentProperty)srcProperty).Body;
                    ItemConversion.ConvertAnyMimeToItem(itemOut, body, inboundConversionOptions);
                    goto IL_8A;
                }
                catch (ExchangeDataException ex)
                {
                    throw new ConversionException("Mime conversion for MMS item failed due to InvalidCharSetError", ex.InnerException);
                }
                catch (ConversionFailedException ex2)
                {
                    throw new ConversionException("Mime conversion for MMS item failed due to InvalidMime", ex2.InnerException);
                }
            }
            base.InternalCopyFromModified(srcProperty);
IL_8A:
            if (string.Equals(base.XsoItem.ClassName, "IPM.NOTE.MOBILE.SMS", StringComparison.OrdinalIgnoreCase))
            {
                MessageItem  messageItem  = (MessageItem)base.XsoItem;
                StreamReader streamReader = new StreamReader(((IContentProperty)srcProperty).Body);
                char[]       array        = new char[78];
                int          length       = streamReader.ReadBlock(array, 0, array.Length);
                messageItem.Subject = new string(array, 0, length);
            }
        }
コード例 #7
0
        // Token: 0x06001560 RID: 5472 RVA: 0x0007D5CC File Offset: 0x0007B7CC
        protected void ParseMimeToMessage(MessageItem message)
        {
            if (message == null)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemCreationFailed");
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MailSubmissionFailed, null, false);
            }
            Stream stream;

            if (base.Version < 140)
            {
                stream = base.InputStream;
            }
            else
            {
                AirSyncBlobXmlNode airSyncBlobXmlNode = base.Request.CommandXml["Mime"] as AirSyncBlobXmlNode;
                stream = airSyncBlobXmlNode.Stream;
                stream.Seek(0L, SeekOrigin.Begin);
            }
            InboundConversionOptions inboundConversionOptions = AirSyncUtility.GetInboundConversionOptions();

            inboundConversionOptions.ClearCategories = false;
            try
            {
                ItemConversion.ConvertAnyMimeToItem(message, stream, inboundConversionOptions);
            }
            catch (ExchangeDataException innerException)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidCharSetError");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException, false);
            }
            catch (ConversionFailedException innerException2)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SendMailMimeError");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidMIME, innerException2, false);
            }
            message.From = null;
            IConfigurationSession    tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(Command.CurrentOrganizationId), 854, "ParseMimeToMessage", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\SendMailBase.cs");
            TransportConfigContainer transportConfigContainer             = tenantOrTopologyConfigurationSession.FindSingletonConfigurationObject <TransportConfigContainer>();

            base.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, tenantOrTopologyConfigurationSession.LastUsedDc);
            bool flag = transportConfigContainer == null || !transportConfigContainer.OpenDomainRoutingEnabled;

            if (flag && SendMailBase.DefaultDomain != null)
            {
                IList <Recipient> list = new List <Recipient>();
                foreach (Recipient recipient in message.Recipients)
                {
                    if (recipient.Participant.RoutingType == null || (recipient.Participant.RoutingType == "SMTP" && recipient.Participant.EmailAddress.IndexOf('@') == -1))
                    {
                        list.Add(recipient);
                    }
                }
                foreach (Recipient recipient2 in list)
                {
                    Participant participant = this.ResolveUnresolvedParticipant(recipient2.Participant);
                    message.Recipients.Remove(recipient2);
                    message.Recipients.Add(participant, recipient2.RecipientItemType);
                }
                IList <Participant> list2 = new List <Participant>();
                foreach (Participant participant2 in message.ReplyTo)
                {
                    if (participant2.RoutingType == null || (participant2.RoutingType == "SMTP" && participant2.EmailAddress.IndexOf('@') == -1))
                    {
                        list2.Add(participant2);
                    }
                }
                foreach (Participant participant3 in list2)
                {
                    Participant item = this.ResolveUnresolvedParticipant(participant3);
                    message.ReplyTo.Remove(participant3);
                    message.ReplyTo.Add(item);
                }
            }
            if (message.Recipients.Count == 0)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MessageHasNoRecipient");
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.MessageHasNoRecipient, null, false);
            }
        }
コード例 #8
0
        public void AddAttachment(Attachment attachment, IRecipientSession adRecipientSession)
        {
            bool     flag     = false;
            MimePart mimePart = attachment.MimePart;
            Header   header   = null;

            if (mimePart != null)
            {
                header = mimePart.Headers.FindFirst("X-MS-Exchange-Organization-Approval-AttachToApprovalRequest");
            }
            string text;

            if (header != null && header.TryGetValue(out text))
            {
                if (text.Equals("Never"))
                {
                    return;
                }
                if (text.Equals("AsMessage"))
                {
                    flag = true;
                }
            }
            if (flag)
            {
                using (Stream contentReadStream = attachment.GetContentReadStream())
                {
                    using (ItemAttachment itemAttachment = (ItemAttachment)this.messageItem.AttachmentCollection.Create(AttachmentType.EmbeddedMessage))
                    {
                        using (Item item = itemAttachment.GetItem())
                        {
                            ItemConversion.ConvertAnyMimeToItem(item, contentReadStream, new InboundConversionOptions(Components.Configuration.FirstOrgAcceptedDomainTable.DefaultDomainName)
                            {
                                UserADSession = adRecipientSession
                            });
                            item[MessageItemSchema.Flags] = MessageFlags.None;
                            item.Save(SaveMode.NoConflictResolution);
                            string valueOrDefault = item.GetValueOrDefault <string>(ItemSchema.Subject);
                            if (!string.IsNullOrEmpty(valueOrDefault))
                            {
                                itemAttachment[AttachmentSchema.DisplayName] = valueOrDefault;
                            }
                            itemAttachment.Save();
                        }
                    }
                    return;
                }
            }
            using (StreamAttachment streamAttachment = (StreamAttachment)this.messageItem.AttachmentCollection.Create(AttachmentType.Stream))
            {
                streamAttachment.FileName = attachment.FileName;
                using (Stream contentStream = streamAttachment.GetContentStream())
                {
                    using (Stream contentReadStream2 = attachment.GetContentReadStream())
                    {
                        ApprovalProcessor.CopyStream(contentReadStream2, contentStream, this.Buffer);
                    }
                    contentStream.Flush();
                }
                streamAttachment.Save();
            }
        }