Even looking into MSDN's Exchange 2013 - 101 Code Samples, I could not find an example creating notes using EWS Managed 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. Or, is it possible there is no API for creating notes in this library?
3 Answers
1
votes
A PostItem isn't the same as a note in the Notes folder. PostItem's represent items with a message class of IPM.Post. Notes, on the other hand, use the message class IPM.StickyNote. The managed API has no direct support for these items. You can retrieve them as EmailMessage objects, and you can even create them as EmailMessage objects if you manually set the required properties. Glen has a good write-up on his blog: http://gsexdev.blogspot.com/2009/07/creating-sticky-notes-in-ews-managed.html
0
votes
Take a look at the PostItem, they should do what you want. 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();
}
0
votes
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);