Работа с MapiJournal в PST
Contents
[
Hide
]
Добавление MapiJournal в PST
С помощью Aspose.Email вы можете добавить MapiJournal в подпапку Журнал файла PST, который вы создали или загрузили. Ниже приведены шаги для добавления MapiJournal в PST:
- Создайте объект MapiJournal
- Установите свойства MapiJournal с помощью конструктора и методов.
- Создайте PST с помощью метода PersonalStorage.Create().
- Создайте предопределенную папку (Журналы) в корне файла PST, получив доступ к корневой папке и затем вызвав метод AddMapiMessageItem().
Следующий фрагмент кода показывает, как создать MapiJournal и затем добавить его в папку журналов только что созданного файла PST.
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); | |
} |
Добавление вложений в MapiJournal
Следующий фрагмент кода показывает, как добавить вложения в 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"); |