Lotus Notes - 以编程方式保存损坏的附件 - NotesEmbeddedObject

发布于 2024-11-16 19:49:02 字数 945 浏览 2 评论 0原文

我有一个 NSF,其中包含一封带有两个附件的电子邮件。其中一个附件已损坏,如果我尝试保存它,Notes 将显示此消息 附件可能已损坏。您想继续使用可用数据吗?

如果我单击“是”,Notes 会将损坏的附件保存到我指定的目录中。这很好。

我想使用 C# 中的对象模型做同样的事情。如果我运行 NotesEmbeddedObject.ExtractFile(),我会收到以下异常消息:Notes 错误:编码数据校验和不匹配 - 附件可能已损坏。没有文件版本写入我指定的目录。

我希望代码将损坏的版本写入目录。我该怎么做?

现有代码:

//BEGIN Extract Attachment
//nItem is a NotesItem
if (nItem.type == IT_TYPE.ATTACHMENT)
{
    try
    {
        string pAttachment = ((object[])nItem.Values)[0].ToString();
        NotesDocument NDoc =  NotesConnectionDatabase.AllDocuments.GetNthDocument(i);
        NotesEmbeddedObject Neo = NDoc.GetAttachment(pAttachment);
        NDoc.GetAttachment(pAttachment).ExtractFile(@"D:\projects\xxx\Attach\" + pAttachment);
    }
    catch (Exception e)
    {
        string eMessage = e.Message;
        Console.WriteLine(eMessage);
    }
}
//END Extract Attachment

I have an NSF that contains an email message with two attachments. One of the attachments is corrupt, and if I attempt to save it, Notes displays this message The attachment may be corrupted. Would you like to continue with the available data?

If I click Yes, Notes saves the corrupt attachment to the directory I specify. This is good.

I would like to do the same thing using the object model in C#. If I run NotesEmbeddedObject.ExtractFile(), I receive this exception message: Notes error: Encoded Data Checksum Mismatch - Attachment may be corrupted. No version of the file is written to the directory I specify.

I would like for the code to write the corrupted version to a directory. How can I do this?

Existing Code:

//BEGIN Extract Attachment
//nItem is a NotesItem
if (nItem.type == IT_TYPE.ATTACHMENT)
{
    try
    {
        string pAttachment = ((object[])nItem.Values)[0].ToString();
        NotesDocument NDoc =  NotesConnectionDatabase.AllDocuments.GetNthDocument(i);
        NotesEmbeddedObject Neo = NDoc.GetAttachment(pAttachment);
        NDoc.GetAttachment(pAttachment).ExtractFile(@"D:\projects\xxx\Attach\" + pAttachment);
    }
    catch (Exception e)
    {
        string eMessage = e.Message;
        Console.WriteLine(eMessage);
    }
}
//END Extract Attachment

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后来的我们 2024-11-23 19:49:02

恐怕不是。

NotesEmbeddedObject.ExtractFile 方法尝试提取附件,但存在校验和不匹配的情况,一旦收到该错误,就会引发异常。

我不知道有任何其他处理附件的 Notes 后端类(也许其他人知道......)

I'm afraid not.

The NotesEmbeddedObject.ExtractFile method attempts to extract the attachment, but there's a checksum mismatch, and as soon as it gets that error, it throws an exception.

I don't know of any other Notes back-end classes that deal with attachments (maybe someone else does...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文