PST에서 MapiNote 작업
Contents
[
Hide
]
Outlook 메모는 스티키 노트의 전자 버전으로, 짧은 텍스트와 색상, 창 크기를 가집니다. Aspose.Email for C++는 메모를 MapiNote 클래스이며, PST 파일은 메모 역할이 있는 폴더에 메모를 보관합니다.
이 문서의 샘플은 다음 헤더와 네임스페이스를 사용합니다:
#include <Mapi/MapiMessage.h>
#include <Mapi/MapiNote.h>
#include <Mapi/NoteColor.h>
#include <Mapi/MapiItemType.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/convert.h>
using namespace System;
using namespace Aspose::Email::Mapi;
using namespace Aspose::Email::Storage::Pst;
PST에 MapiNote 추가
메모에는 템플릿이 필요하지 않습니다: MapiNote 생성자는 제목과 본문을 받으며, 색상, 너비 및 높이 속성은 Outlook이 메모를 그리는 방식을 정의합니다. 색상은 NoteColor 값; 메모에 값이 없으면 노란색입니다.
메모는 다음으로 만든 폴더에 저장됩니다 StandardIpmFolder::Notes, Outlook이 메모 보기에서 열도록 합니다. 일반적인 방식으로 다시 읽을 수 있습니다: ExtractMessage returns a MapiMessage, 그리고 메모 항목의 경우 ToMapiMessageItem 제공합니다 MapiNote 색상과 크기를 포함하여.
auto yellow = MakeObject<MapiNote>(u"Shopping list", u"Milk, bread, coffee");
auto pink = MakeObject<MapiNote>(u"Birthday", u"Buy a present for Anna");
pink->set_Color(NoteColor::Pink);
auto blue = MakeObject<MapiNote>(u"Meeting room", u"Book room 4 for Thursday");
blue->set_Color(NoteColor::Blue);
blue->set_Width(500);
blue->set_Height(300);
auto pst = PersonalStorage::Create(u"Notes.pst", FileFormatVersion::Unicode);
auto notesFolder = pst->CreatePredefinedFolder(u"Notes", StandardIpmFolder::Notes);
notesFolder->AddMapiMessageItem(yellow);
notesFolder->AddMapiMessageItem(pink);
notesFolder->AddMapiMessageItem(blue);
for (auto messageInfo : notesFolder->EnumerateMessages())
{
auto message = pst->ExtractMessage(messageInfo);
if (message->get_SupportedType() != MapiItemType::Note)
{
continue;
}
auto note = DynamicCast<MapiNote>(message->ToMapiMessageItem());
Console::WriteLine(note->get_Subject() + u": " + Convert::ToString(note->get_Width()) + u"x" + Convert::ToString(note->get_Height()) +
(note->get_Color() == NoteColor::Yellow ? u", default colour" : u", custom colour"));
}
pst->Dispose();