C++에서 Outlook 메모 생성, 저장 및 읽기
Contents
[
Hide
]
**Aspose.Email for C++**는 Outlook 메모를 프로그래밍 방식으로 생성하고 관리할 수 있게 합니다. The MapiNote 클래스는 메모를 만들고 사용자 지정하는 데 필요한 모든 핵심 속성(예: 제목, 본문 텍스트, 색상 및 크기)을 제공합니다.
이 문서는 MSG 형식으로 저장된 Outlook 메모를 만들고, 저장하고, 읽는 방법을 보여줍니다. PST 파일에 메모를 저장하는 방법은 다음에서 다룹니다 PST에서 MapiNote 작업.
이 문서의 샘플은 다음 헤더와 네임스페이스를 사용합니다:
#include <Mapi/MapiMessage.h>
#include <Mapi/MapiNote.h>
#include <Mapi/NoteColor.h>
#include <Mapi/NoteSaveFormat.h>
#include <Mapi/MapiItemType.h>
#include <system/convert.h>
using namespace System;
using namespace Aspose::Email::Mapi;
Outlook 메모 생성 및 저장
Outlook 메모를 생성하고 디스크에 저장하려면 아래 단계를 따르세요:
- 인스턴스화합니다 MapiNote 객체.
- 제목, 본문, 색상, 높이 및 너비와 같은 메모 속성을 설정합니다.
- 다음으로 메모를 저장합니다 MapiNote::Save 및
NoteSaveFormat::Msg.
색상은 다음 중 하나입니다 NoteColor 값; 폭과 높이는 Outlook이 메모를 여는 창의 픽셀 크기를 지정합니다.
SharedPtr<MapiNote> note = MakeObject<MapiNote>();
note->set_Subject(u"Blue color note");
note->set_Body(u"This is a blue color note");
note->set_Color(NoteColor::Blue);
note->set_Height(500);
note->set_Width(500);
note->Save(u"MapiNote_out.msg", NoteSaveFormat::Msg);
Outlook 메모 읽기
MSG 파일로 저장된 메모는 다음으로 로드됩니다 MapiMessage, 그리고 ToMapiMessageItem 메모로 변환합니다 MapiNote. 검사 중 get_SupportedType 파일이 실제로 메모인지 확인합니다 - DynamicCast 항목 타입이 다르면 예외가 발생합니다.
SharedPtr<MapiMessage> message = MapiMessage::Load(u"MapiNote_out.msg");
if (message->get_SupportedType() == MapiItemType::Note)
{
SharedPtr<MapiNote> note = DynamicCast<MapiNote>(message->ToMapiMessageItem());
Console::WriteLine(u"Subject: " + note->get_Subject());
Console::WriteLine(u"Body: " + note->get_Body());
Console::WriteLine(u"Size: " + Convert::ToString(note->get_Width()) + u"x" + Convert::ToString(note->get_Height()));
Console::WriteLine(String(u"Blue: ") + (note->get_Color() == NoteColor::Blue ? u"yes" : u"no"));
}