简体   繁体   English

如何使用EWS托管API 2.0创建笔记

[英]How to create notes using EWS Managed API 2.0

Even looking into MSDN's Exchange 2013 - 101 Code Samples , I could not find an example creating notes using EWS Managed API 2.0. 即使查看MSDN的Exchange 2013-101代码示例 ,我也找不到使用EWS托管API 2.0创建注释的示例。 On Folders and items in EWS in Exchange , the most appropriate item type seems to me PostItem but my test failed trying to create such items in Notes folder. 在Exchange中的EWS中的文件夹和项目上 ,最合适的项目类型在我看来是PostItem,但是我的测试未能尝试在Notes文件夹中创建此类项目。 Or, is it possible there is no API for creating notes in this library? 或者,该库中可能没有用于创建笔记的API吗?

A PostItem isn't the same as a note in the Notes folder. PostItem与Notes文件夹中的注释不同。 PostItem's represent items with a message class of IPM.Post . PostItem代表消息类为IPM.Post Notes, on the other hand, use the message class IPM.StickyNote . 另一方面,Notes使用消息类IPM.StickyNote The managed API has no direct support for these items. 托管API不直接支持这些项目。 You can retrieve them as EmailMessage objects, and you can even create them as EmailMessage objects if you manually set the required properties. 您可以将它们检索为EmailMessage对象,如果手动设置所需的属性,甚至可以将它们创建为EmailMessage对象。 Glen has a good write-up on his blog: http://gsexdev.blogspot.com/2009/07/creating-sticky-notes-in-ews-managed.html 格伦在他的博客上写得很好: http//gsexdev.blogspot.com/2009/07/creating-sticky-notes-in-ews-managed.html

Take a look at the PostItem, they should do what you want. 看一下PostItem,他们应该做您想要的。 PostItem PostItem

Sample 样品

var items = new List<PostItem>();

for (int i = 0; i != 10; ++i)
{
    var m = new PostItem(service);
    m.Subject = "Note " + i.ToString();
    m.Body = new MessageBody(BodyType.Text, "A test note");
    m.Save();
}
var guid = new Guid("0006200E-0000-0000-C000-000000000046");
var colour = new ExtendedPropertyDefinition(guid, 0x8B00, MapiPropertyType.Integer);
var width = new ExtendedPropertyDefinition(guid, 0x8B02, MapiPropertyType.Integer);
var height = new ExtendedPropertyDefinition(guid, 0x8B03, MapiPropertyType.Integer);
var left = new ExtendedPropertyDefinition(guid, 0x8B04, MapiPropertyType.Integer);
var top = new ExtendedPropertyDefinition(guid, 0x8B05, MapiPropertyType.Integer);

var items = new List<EmailMessage>();
for (int i = 0; i != maxItems; ++i)
{
    var m = new EmailMessage(service);
    m.Subject = "Note " + i.ToString();
    m.ItemClass = "IPM.StickyNote";
    m.Body = new MessageBody(BodyType.Text, "A test note");
    m.SetExtendedProperty(colour, 1);
    m.SetExtendedProperty(width, 200);
    m.SetExtendedProperty(height, 166);
    m.SetExtendedProperty(left, 200);
    m.SetExtendedProperty(top, 200);
    items.Add(m);
}

var folder = Folder.Bind(service, WellKnownFolderName.Notes, new PropertySet());
var responses = service.CreateItems(items, folder.Id, MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM