IBM Notes (NSF) ファイルの操作
Contents
[
Hide
]
IBM Notes (現在は HCL Notes) はメール、カレンダーエントリ、アプリケーションデータを NSF データベース—Notes Storage Facility フォーマット—に保持します。Aspose.Email for C++ はそのようなデータベースを認識し、 NotesStorageFacility クラスの Aspose::Email::Storage::Nsf 名前空間。Notes クライアントや Domino サーバは不要です。
以下のサンプルは次のヘッダーと名前空間を使用しています:
#include <MailMessage.h>
#include <SaveOptions.h>
#include <EmlSaveOptions.h>
#include <Storage/Nsf/NotesStorageFacility.h>
#include <Tools/FileFormat/FileFormatUtil.h>
#include <Tools/FileFormat/FileFormatInfo.h>
#include <Tools/FileFormat/FileFormatType.h>
#include <system/io/file.h>
#include <system/io/directory.h>
#include <system/convert.h>
using namespace System;
using namespace Aspose::Email;
using namespace Aspose::Email::Tools;
using namespace Aspose::Email::Storage::Nsf;
NSF フォーマットの検出
未知の出所のファイルを開く前に、確認してください FileFormatUtil::DetectFileFormat それが何か。返された FileFormatInfo レポート FileFormatType::Nsf Notes データベース用です。
SharedPtr<FileFormatInfo> info = FileFormatUtil::DetectFileFormat(u"SampleNSF.nsf");
if (info->get_FileFormatType() == FileFormatType::Nsf)
{
Console::WriteLine(u"The file is an IBM Notes storage (NSF).");
}
メッセージを読む
データベースを NotesStorageFacility コンストラクタ - ファイルパスまたはストリーム、オプションで NsfLoadOptions - そして反復処理 EnumerateMessages。各項目は MailMessage、したがって件名、アドレス、本文、添付ファイルは EML ファイルと同じように利用可能です。
SharedPtr<NotesStorageFacility> nsf = MakeObject<NotesStorageFacility>(u"SampleNSF.nsf");
// messages come out one by one as regular MailMessage objects
for (SharedPtr<MailMessage> eml : nsf->EnumerateMessages())
{
Console::WriteLine(eml->get_Subject());
}
nsf->Dispose();
ストリームからメッセージをエクスポート
ストリームコンストラクタは、データベースがローカルディスク上にない場合に便利です。この例はメッセージを読み取り、各メッセージを EML ファイルとして保存します。他のすべての SaveOptions - MSG、MHTML、HTML - も同様に動作します。
SharedPtr<IO::FileStream> stream = IO::File::OpenRead(u"SampleNSF.nsf");
SharedPtr<NotesStorageFacility> nsf = MakeObject<NotesStorageFacility>(stream);
IO::Directory::CreateDirectory_(u"NsfExport");
int32_t index = 0;
for (SharedPtr<MailMessage> eml : nsf->EnumerateMessages())
{
// any MailMessage output format is available: EML, MSG, MHTML...
eml->Save(String::Format(u"NsfExport\\message_{0}.eml", index++), SaveOptions::get_DefaultEml());
}
Console::WriteLine(u"Exported messages: " + Convert::ToString(index));
nsf->Dispose();
stream->Close();
NSF のサポートはメールメッセージの読み取りに限定され、データベースのフォルダー構造は公開されません。Notes 7 以降で作成されたデータベースや LZ1 圧縮を使用したデータベースは読み取れない可能性があります。