Làm việc với MapiNote trong PST
Ghi chú Outlook là phiên bản điện tử của ghi chú dán: một đoạn văn bản ngắn với màu và kích thước cửa sổ. Aspose.Email for C++ đại diện cho một ghi chú bằng MapiNote lớp, và một tệp PST lưu ghi chú trong một thư mục có vai trò ghi chú.
Mẫu trong bài viết này sử dụng các tiêu đề và không gian tên này:
#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;
Thêm MapiNote vào PST
Một ghi chú không cần mẫu: the MapiNote trình tạo nhận tiêu đề và nội dung, và Màu, Chiều rộng và Chiều cao các thuộc tính xác định cách Outlook vẽ nó. Màu là một NoteColor giá trị; một ghi chú không có giá trị này sẽ có màu vàng.
Các ghi chú được lưu trong một thư mục được tạo bằng StandardIpmFolder::Notes, vì vậy Outlook mở nó trong chế độ xem ghi chú. Đọc lại chúng hoạt động theo cách thông thường: ExtractMessage trả về một MapiMessage, và đối với một mục ghi chú ToMapiMessageItem cung cấp MapiNote với màu và kích thước của nó.
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();