コード例 #1
0
        // Token: 0x06000039 RID: 57 RVA: 0x00003EA4 File Offset: 0x000020A4
        private void SendRejectNotification(MessageItem messageItem)
        {
            ModeratedDLApplication.diag.TraceDebug((long)this.GetHashCode(), "Entering SendRejectNotification");
            if (!this.ShouldSendNotification(messageItem))
            {
                return;
            }
            RoutingAddress routingAddress;

            if (!this.TryGetOriginalSender(messageItem, out routingAddress))
            {
                return;
            }
            MailboxSession mailboxSession = (MailboxSession)messageItem.Session;

            messageItem.Load(ModeratedDLApplication.NotificationPropertiesFromInitMessage);
            string valueOrDefault = messageItem.GetValueOrDefault <string>(MessageItemSchema.AcceptLanguage, string.Empty);
            DsnHumanReadableWriter defaultDsnHumanReadableWriter = DsnHumanReadableWriter.DefaultDsnHumanReadableWriter;
            ICollection <string>   moderatedRecipients           = this.GetModeratedRecipients(messageItem, false);
            string        valueOrDefault2 = messageItem.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty);
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Outbox);

            using (MessageItem messageItem2 = MessageItem.Create(mailboxSession, defaultFolderId))
            {
                StreamAttachment streamAttachment = null;
                try
                {
                    bool flag = ModeratedDLApplication.TryGetCommentAttachment(messageItem, out streamAttachment) && streamAttachment.Size > 0L;
                    messageItem2.ClassName = "IPM.Note.Microsoft.Approval.Reply.Reject";
                    bool flag2 = true;
                    ApprovalInformation approvalInformation = null;
                    if (flag)
                    {
                        approvalInformation  = defaultDsnHumanReadableWriter.GetModerateRejectInformation(messageItem.Subject, moderatedRecipients, flag, valueOrDefault2, valueOrDefault);
                        messageItem2.Subject = approvalInformation.Subject;
                        flag2 = this.TryWriteNotificationWithAppendedComments(defaultDsnHumanReadableWriter, messageItem2, streamAttachment, approvalInformation);
                    }
                    if (!flag || !flag2)
                    {
                        approvalInformation  = defaultDsnHumanReadableWriter.GetModerateRejectInformation(messageItem.Subject, moderatedRecipients, false, valueOrDefault2, valueOrDefault);
                        messageItem2.Subject = approvalInformation.Subject;
                        BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, approvalInformation.MessageCharset.Name);
                        using (Stream stream = messageItem2.Body.OpenWriteStream(configuration))
                        {
                            defaultDsnHumanReadableWriter.WriteHtmlModerationBody(stream, approvalInformation);
                            stream.Flush();
                        }
                    }
                    if (flag && !flag2)
                    {
                        using (StreamAttachment streamAttachment2 = messageItem2.AttachmentCollection.Create(AttachmentType.Stream) as StreamAttachment)
                        {
                            streamAttachment2.FileName = defaultDsnHumanReadableWriter.GetModeratorsCommentFileName(approvalInformation.Culture);
                            using (Stream contentStream = streamAttachment2.GetContentStream())
                            {
                                using (Stream contentStream2 = streamAttachment.GetContentStream(PropertyOpenMode.ReadOnly))
                                {
                                    byte[] buffer = new byte[8192];
                                    ApprovalProcessor.CopyStream(contentStream2, contentStream, buffer);
                                }
                                contentStream.Flush();
                            }
                            streamAttachment2.Save();
                        }
                    }
                    this.StampCommonNotificationProperties(messageItem2, messageItem, new RoutingAddress[]
                    {
                        routingAddress
                    }, valueOrDefault2, approvalInformation.Culture);
                    messageItem2.SendWithoutSavingMessage();
                }
                finally
                {
                    if (streamAttachment != null)
                    {
                        streamAttachment.Dispose();
                    }
                }
            }
        }