Trabalhando com MapiJournal em PST
Contents
[
Hide
]
Adicionando MapiJournal ao PST
Com Aspose.Email, você pode adicionar MapiJournal à subpasta Journal de um arquivo PST que você criou ou carregou. Abaixo estão os passos para adicionar MapiJournal a um PST:
- Crie um objeto MapiJournal
- Defina as propriedades do MapiJournal usando um construtor e métodos.
- Crie um PST usando o método PersonalStorage.Create().
- Crie uma pasta pré-definida (Journals) na raiz do arquivo PST acessando a pasta raiz e, em seguida, chamando o método AddMapiMessageItem().
O seguinte trecho de código mostra como criar um MapiJournal e, em seguida, adicioná-lo à pasta de diário de um arquivo PST recém-criado.
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); | |
} |
Adicionando Anexos ao MapiJournal
O seguinte trecho de código mostra como adicionar anexos ao 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"); |