IBM Notes (NSF) फ़ाइलों के साथ काम करना
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();