PST에서 MapiJournal 작업

Outlook 저널 항목은 활동을 기록합니다 - 전화 통화, 회의, 문서 작업 - 시작 및 종료 시각과 함께. Aspose.Email for C++에서 이러한 항목은 MapiJournal 객체는 PST 파일의 저널 폴더에 다른 Outlook 항목처럼 저장될 수 있습니다.

이 문서의 샘플은 다음 헤더와 네임스페이스를 사용합니다:

#include <Mapi/MapiMessage.h>
#include <Mapi/MapiJournal.h>
#include <Mapi/MapiAttachment.h>
#include <Mapi/MapiAttachmentCollection.h>
#include <Storage/Pst/PersonalStorage.h>
#include <Storage/Pst/FolderInfo.h>
#include <Storage/Pst/MessageInfo.h>
#include <Storage/Pst/FileFormatVersion.h>
#include <Storage/Pst/StandardIpmFolder.h>
#include <system/array.h>
#include <system/convert.h>
#include <system/io/file.h>
#include <system/io/path.h>

using namespace System;
using namespace Aspose::Email::Mapi;
using namespace Aspose::Email::Storage::Pst;

PST에 MapiJournal 추가

다음은 MapiJournal 생성자는 제목, 본문, Outlook이 표시하는 활동 유형(예: "전화 통화") 및 간단한 설명을 받습니다. 기간과 관련 회사는 속성을 통해 설정됩니다.

Outlook 저널 보기에서 표시하려면, 항목은 저널 역할이 있는 폴더에 있어야 합니다. CreatePredefinedFolder 와 함께 StandardIpmFolder::Journal 해당 폴더를 만들고, FolderInfo::AddMapiMessageItem 항목을 저장합니다.

auto journal = MakeObject<MapiJournal>(u"Call with the supplier", u"Agreed on the delivery dates for May.",
    u"Phone call", u"Phone call");
journal->set_StartTime(DateTime(2025, 4, 14, 10, 0, 0));
journal->set_EndTime(journal->get_StartTime().AddMinutes(25));
journal->set_Companies(MakeArray<String>({u"Northwind Traders", u"Contoso"}));

auto pst = PersonalStorage::Create(u"Journal.pst", FileFormatVersion::Unicode);
auto journalFolder = pst->CreatePredefinedFolder(u"Journal", StandardIpmFolder::Journal);
journalFolder->AddMapiMessageItem(journal);

Console::WriteLine(u"Entries in the journal folder: " + Convert::ToString(journalFolder->get_ContentCount()));
pst->Dispose();

MapiJournal에 첨부 파일 추가

활동과 관련된 문서 - 회의록, 전화 통화 중 논의된 견적 - 은 저널 항목에 첨부 파일로 함께 전달될 수 있습니다. get_Attachments 반환합니다 MapiAttachmentCollection 항목의, 그 Add 이 메서드는 파일 이름과 첨부 파일 내용을 받습니다. 샘플은 위에서 만든 저장소에 해당 항목을 추가합니다.

auto journal = MakeObject<MapiJournal>(u"Quote review", u"Went through the quote with the sales team.",
    u"Meeting", u"Meeting");
journal->set_StartTime(DateTime(2025, 4, 15, 14, 0, 0));
journal->set_EndTime(journal->get_StartTime().AddHours(1));

for (String file : MakeArray<String>({u"1.jpg", u"Attachments.eml"}))
{
    journal->get_Attachments()->Add(IO::Path::GetFileName(file), IO::File::ReadAllBytes(file));
}

auto pst = PersonalStorage::FromFile(u"Journal.pst", true);
auto journalFolder = pst->GetPredefinedFolder(StandardIpmFolder::Journal);
journalFolder->AddMapiMessageItem(journal);

// read the entries back and list their attachments
for (auto messageInfo : journalFolder->EnumerateMessages())
{
    auto message = pst->ExtractMessage(messageInfo);
    Console::WriteLine(message->get_Subject() + u": " + Convert::ToString(message->get_Attachments()->get_Count()) + u" attachments");
}

pst->Dispose();