简体   繁体   English

使用Aspose.Email打开嵌入的PDF附件时出错,然后加载到Datalogics中

[英]Error using Aspose.Email to open an embedded PDF attachment, then load into Datalogics

I am using using the Aspose.Email to get attachments out of an Outlook email like this: 我正在使用Aspose.Email从Outlook电子邮件中获取附件,如下所示:

var mailMessage = Aspose.Email.Mail.MailMessage.Load(stream);
var attachments = Aspose.Email.Outlook.MapiMessage.FromMailMessage(mailMessage).Attachments;
var pdfAttachment = attachments.ToList()[attachmentIndexDesired];

Then, I am loading the attachment into DataLogics like this: 然后,我将附件加载到DataLogics中,如下所示:

var pdfStream = new MemoryStream(pdfAttachment.BinaryData);
var pdfDocument = new Datalogics.PDFL.Document(pdfStream);

Here I get the following exception: 在这里,我得到以下异常:

PDF Library Error: File does not begin with '%PDF-'. PDF库错误:文件不以'%PDF-'开头。 Error number: 537001985 错误号码:537001985

I cannot find anything on this error anywhere. 我在任何地方找不到任何关于此错误的信息。

Note that the initial stream object above is a *.msg Outlook file and originates from a sharepoint SPFile. 请注意,上面的初始流对象是* .msg Outlook文件,源自共享点SPFile。 Also note that if the stream object SPFile is itself a PDF file (as opposed to an attachment to a *.msg file) I can load it into DataLogics just fine. 另请注意,如果流对象SPFile本身是PDF文件(而不是* .msg文件的附件),我可以将其加载到DataLogics中。

I know the error is being thrown by the DataLogics library, but is there something about how I am getting the attachment that could be changed/improved that would prevent this error from occurring? 我知道DataLogics库正在抛出错误,但是有什么关于我如何获得可以更改/改进的附件以防止发生此错误?

Any ideas? 有任何想法吗?

So just a few minutes ago I was trying to grab the BinaryData from the attachment and convert it to a string that I could read so I could visually inspect its contents. 所以就在几分钟前我试图从附件中抓取BinaryData并将其转换为我能读取的字符串,以便我可以直观地检查其内容。 So I did this. 所以我这样做了。

(new StreamReader(new MemoryStream(curAttachment.BinaryData))).ReadToEnd()

When I did that, it printed this error: 当我这样做时,它打印出这个错误:

"Evaluation copy of Aspose.Email limits to extract only 3 attachments in the messages. Please contact sales@aspose.com to purchase a valid license."

Kind of strange as I am using my production license, but either way I went ahead and deleted some attachments from the parent *.msg file (it previously had 4) and tried to load it again. 有点奇怪,因为我正在使用我的生产许可证,但无论哪种方式我继续从父* .msg文件(它以前有4)删除了一些附件,并试图再次加载它。 Then... poof... it started working. 然后......噗......开始工作了。

Seems like it should throw an exception or something instead as that would have made this issue a lot easier to track down. 似乎它应该抛出异常或其他东西,因为这会使这个问题更容易追踪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM