Working with MapiJournal in PST
Contents
[
Hide
]
Adding MapiJournal to PST
With Aspose.Email you can add MapiJournal to hte Journal subfolder of a PST file that you have created or loaded. Below are the steps to add MapiJournal to a PST:
- Create a MapiJournal object
- Set the MapiJournal properties using a constructor and methods.
- Create a PST using the PersonalStorage.Create() method.
- Create a pre-defined folder (Journals) at the root of the PST file by accessing the root folder and then calling the AddMapiMessageItem() method.
The following code snippet shows you how to create a MapiJournal and then add it to the journal folder of a newly created PST file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C | |
System::String dataDir = RunExamples::GetDataDir_Outlook(); | |
System::SharedPtr<MapiJournal> journal = System::MakeObject<MapiJournal>(L"daily record", L"called out in the dark", L"Phone call", L"Phone call"); | |
journal->set_StartTime(System::DateTime::get_Now()); | |
journal->set_EndTime(journal->get_StartTime().AddHours(1)); | |
System::String path = dataDir + L"CreateNewMapiJournalAndAddToSubfolder_out.pst"; | |
if (System::IO::File::Exists(path)) | |
{ | |
System::IO::File::Delete(path); | |
} | |
{ | |
System::SharedPtr<PersonalStorage> personalStorage = PersonalStorage::Create(dataDir + L"CreateNewMapiJournalAndAddToSubfolder_out.pst", Aspose::Email::Outlook::Pst::FileFormatVersion::Unicode); | |
System::SharedPtr<FolderInfo> journalFolder = personalStorage->CreatePredefinedFolder(L"Journal", Aspose::Email::Outlook::Pst::StandardIpmFolder::Journal); | |
journalFolder->AddMapiMessageItem(journal); | |
} |
Adding Attachments to MapiJournal
The following code snippet shows you how to add attachments to MapiJournal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C | |
System::String dataDir = RunExamples::GetDataDir_Outlook(); | |
System::ArrayPtr<System::String> attachFileNames = System::MakeArray<System::String>({dataDir + L"Desert.jpg", dataDir + L"download.png"}); | |
System::SharedPtr<MapiJournal> journal = System::MakeObject<MapiJournal>(L"testJournal", L"This is a test journal", L"Phone call", L"Phone call"); | |
journal->set_StartTime(System::DateTime::get_Now()); | |
journal->set_EndTime(journal->get_StartTime().AddHours(1)); | |
journal->set_Companies(System::MakeArray<System::String>({L"company 1", L"company 2", L"company 3"})); | |
{ | |
for (int i_ = 0; i_ < attachFileNames->Count(); ++i_) | |
{ | |
System::String attach = attachFileNames[i_]; | |
{ | |
journal->get_Attachments()->Add(attach, System::IO::File::ReadAllBytes(attach)); | |
} | |
} | |
} | |
journal->Save(dataDir + L"AddAttachmentsToMapiJournal_out.msg"); |