Lotus Notes - 以编程方式保存损坏的附件 - NotesEmbeddedObject
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
恐怕不是。
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...)