Trabajando con MapiJournal en PST
Contents
[
Hide
]
Agregar MapiJournal a PST
Con Aspose.Email puedes agregar MapiJournal a la subcarpeta Journal de un archivo PST que hayas creado o cargado. A continuación se muestran los pasos para agregar MapiJournal a un PST:
- Crea un objeto MapiJournal
- Establece las propiedades de MapiJournal utilizando un constructor y métodos.
- Crea un PST utilizando el método PersonalStorage.Create().
- Crea una carpeta predefinida (Journals) en la raíz del archivo PST accediendo a la carpeta raíz y luego llamando al método AddMapiMessageItem().
El siguiente fragmento de código te muestra cómo crear un MapiJournal y luego agregarlo a la carpeta de diarios de un archivo PST recién creado.
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); | |
} |
Agregar Archivos Adjuntos a MapiJournal
El siguiente fragmento de código te muestra cómo agregar archivos adjuntos a 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"); |