PST での MapiNote の操作

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 戻り値は 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();