การทำงานกับ MapiNote ใน PST
Contents
[
Hide
]
โน้ต Outlook เป็นสื่ออิเล็กทรอนิกส์ของโน้ตกาว: ข้อความสั้นพร้อมสีและขนาดหน้าต่าง Aspose.Email สำหรับ 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;
การเพิ่ม MapiNote ไปยัง PST
โน้ตไม่ต้องการเทมเพลต: the MapiNote Constructor รับหัวเรื่องและเนื้อหา, และ สี, Width และ Height คุณสมบัติกำหนดวิธีที่ Outlook วาดมัน สีเป็น NoteColor ค่า; โน้ตที่ไม่มีค่าสีจะเป็นสีเหลือง
โน้ตถูกเก็บในโฟลเดอร์ที่สร้างด้วย StandardIpmFolder::Notes, เพื่อให้ Outlook เปิดในมุมมองโน้ต การอ่านกลับทำตามปกติ: ExtractMessage คืนค่า 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();