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 압축을 사용하는 데이터베이스는 읽을 수 없을 수 있습니다.