示例#1
0
        private bool TryGenerateMessageFromMsgFileData(string defaultDomain)
        {
            bool result;

            using (Stream stream = new MemoryStream(this.MessageFileData))
            {
                using (MessageItem messageItem = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties))
                {
                    using (Stream stream2 = new MemoryStream())
                    {
                        try
                        {
                            InboundConversionOptions inboundConversionOptions = new InboundConversionOptions(defaultDomain);
                            inboundConversionOptions.UserADSession = this.GetRecipientSession();
                            OutboundConversionOptions outboundConversionOptions = new OutboundConversionOptions(defaultDomain);
                            outboundConversionOptions.UserADSession = inboundConversionOptions.UserADSession;
                            ItemConversion.ConvertMsgStorageToItem(stream, messageItem, inboundConversionOptions);
                            if (this.WasSpecifiedByUser("Sender"))
                            {
                                SmtpAddress sender  = this.Sender;
                                Participant sender2 = new Participant(string.Empty, (string)this.Sender, "SMTP");
                                messageItem.Sender = sender2;
                            }
                            ItemConversion.ConvertItemToSummaryTnef(messageItem, stream2, outboundConversionOptions);
                            stream2.Position = 0L;
                            this.message     = EmailMessage.Create(stream2);
                            result           = true;
                        }
                        catch (CorruptDataException ex)
                        {
                            base.WriteVerbose(Strings.UnableToCreateFromMsg(ex.Message));
                            result = false;
                        }
                        catch (ConversionFailedException ex2)
                        {
                            base.WriteVerbose(Strings.UnableToCreateFromMsg(ex2.Message));
                            result = false;
                        }
                        catch (PropertyErrorException ex3)
                        {
                            base.WriteVerbose(Strings.UnableToCreateFromMsg(ex3.Message));
                            result = false;
                        }
                        catch (StoragePermanentException ex4)
                        {
                            base.WriteVerbose(Strings.UnableToCreateFromMsg(ex4.Message));
                            result = false;
                        }
                        catch (StorageTransientException ex5)
                        {
                            base.WriteVerbose(Strings.UnableToCreateFromMsg(ex5.Message));
                            result = false;
                        }
                    }
                }
            }
            return(result);
        }
示例#2
0
 internal static CalendarLog FromFile(FileInfo file)
 {
     if (file.Exists)
     {
         using (MessageItem messageItem = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties))
         {
             using (FileStream fileStream = file.OpenRead())
             {
                 ItemConversion.ConvertMsgStorageToItem(fileStream, messageItem, new InboundConversionOptions(new EmptyRecipientCache(), null));
                 return(new CalendarLog(messageItem, file, null));
             }
         }
     }
     return(null);
 }
        private CalendarLogAnalysis LoadFromFile(CalendarLogId id, UriHandler handler)
        {
            FileInfo fileInfo = new FileInfo(handler.Uri.LocalPath);

            if (fileInfo.Exists)
            {
                using (MessageItem messageItem = MessageItem.CreateInMemory(StoreObjectSchema.ContentConversionProperties))
                {
                    using (FileStream fileStream = fileInfo.OpenRead())
                    {
                        ItemConversion.ConvertMsgStorageToItem(fileStream, messageItem, new InboundConversionOptions(new EmptyRecipientCache(), null));
                        IEnumerable <PropertyDefinition> displayProperties = AnalysisDetailLevels.GetDisplayProperties(this.detailLevel);
                        return(new CalendarLogAnalysis(id, messageItem, displayProperties));
                    }
                }
            }
            throw new ArgumentException("Item argument cannot be resolved.", "item");
        }
示例#4
0
 private void SaveAndCloseCurrentAttachment()
 {
     if (this.currentAttachment != null)
     {
         if (this.currentAttachment.AttachmentType == AttachmentType.EmbeddedMessage)
         {
             ItemAttachment itemAttachment = this.currentAttachment as ItemAttachment;
             if (itemAttachment != null)
             {
                 using (Item item = itemAttachment.GetItem())
                 {
                     ItemConversion.ConvertMsgStorageToItem(this.temporaryStreamForEmbeddedMessage, item, new InboundConversionOptions(new EmptyRecipientCache(), string.Empty));
                     this.temporaryStreamForEmbeddedMessage = null;
                     item.Save(SaveMode.NoConflictResolution);
                 }
             }
         }
         this.currentAttachment.Save();
         this.currentAttachment.Load(null);
         this.messageAttachmentIds.Add(this.currentAttachment.Id);
         this.currentAttachment.Dispose();
         this.currentAttachment = null;
     }
 }