Работа с MapiNote в PST
Contents
[
Hide
]
Добавление MapiNote в PST
Статья Создание нового PST-файла и добавление подкаталогов показывает, как создать PST-файл и добавить подкаталог к нему. С помощью Aspose.Email вы можете добавить MapiNote в подкаталог Заметки PST-файла, который вы создали или загрузили. Чтобы добавить MapiNote в PST:
- Создайте шаблон MapiNote с помощью Microsoft Outlook и сохраните его как MSG-файл.
- Загрузите сохраненную MSG-запись в объект MapiMessage.
- Создайте объект MapiNote и загрузите шаблон MSG-заметки.
- Установите свойства MapiNote.
- Создайте PST с помощью метода PersonalStorage.Create().
- Создайте предопределенную папку (Заметки) в корне PST-файла, получив доступ к корневой папке и затем вызвав метод AddMapiMessageItem().
Следующий фрагмент кода показывает, как создать MapiNote и затем добавить его в папку заметок только что созданного PST-файла.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
MapiMessage mess = MapiMessage.FromFile(dataDir + "Note.msg"); | |
// Create three Notes | |
MapiNote note1 = (MapiNote)mess.ToMapiMessageItem(); | |
note1.Subject = "Yellow color note"; | |
note1.Body = "This is a yellow color note"; | |
MapiNote note2 = (MapiNote)mess.ToMapiMessageItem(); | |
note2.Subject = "Pink color note"; | |
note2.Body = "This is a pink color note"; | |
note2.Color = NoteColor.Pink; | |
MapiNote note3 = (MapiNote)mess.ToMapiMessageItem(); | |
note2.Subject = "Blue color note"; | |
note2.Body = "This is a blue color note"; | |
note2.Color = NoteColor.Blue; | |
note3.Height = 500; | |
note3.Width = 500; | |
string path = dataDir + "AddMapiNoteToPST_out.pst"; | |
if (File.Exists(path)) | |
{ | |
File.Delete(path); | |
} | |
using (PersonalStorage personalStorage = PersonalStorage.Create(dataDir + "AddMapiNoteToPST_out.pst", FileFormatVersion.Unicode)) | |
{ | |
FolderInfo notesFolder = personalStorage.CreatePredefinedFolder("Notes", StandardIpmFolder.Notes); | |
notesFolder.AddMapiMessageItem(note1); | |
notesFolder.AddMapiMessageItem(note2); | |
notesFolder.AddMapiMessageItem(note3); | |
} |