none
[E2007][EWSMA][C#] How Can I Create a Sticky Note with the EWS Managed API RRS feed

  • Question

  • I'm trying to create a sticky note using the EWS Managed API, but without much luck.

    The best I have managed so far is to modify an EmailMessage, but the note ends up in the Drafts folder and not in Notes.

    Is there any way that I can create a Sticky Note and send it to the Notes folder with this API?

    I'm using Exchange Server 2007.

     

    Regards,

    Kevin.




    Friday, June 3, 2011 11:18 AM

Answers

  • EWS datatypes don't map directly to those you see in a mapi editor you should be using Interger datatype eg try

          EmailMessage message = new EmailMessage(service);
          message.ItemClass = "IPM.StickyNote";
          Guid guid = new Guid("0006200E-0000-0000-C000-000000000046");
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B00, MapiPropertyType.Integer), 1);
          // colour
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B02, MapiPropertyType.Integer), 200);
          // width
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B03, MapiPropertyType.Integer), 166);
          // height
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B04, MapiPropertyType.Integer), 200);
          // left
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B05, MapiPropertyType.Integer), 200);
          // top
          message.Subject = "Test Note" ;
          message.Body = new MessageBody("Test of conversion from Email to note"); 
          message.Save(WellKnownFolderName.Notes);
    

    Cheers
    Glen

     

     

    Monday, June 6, 2011 11:36 AM

All replies

  • What does your code look like ? if the Item is ending up in the drafts folder it sounds like your not specifying where to save it eg in your Save method you should have something like

     Item.Save(WellKnownFolderName.Notes)

    This may also help http://gsexdev.blogspot.com/2009/07/creating-sticky-notes-in-ews-managed.html

    Cheers
    Glen


    Saturday, June 4, 2011 4:42 AM
  • Hi Glen,

    Thanks for the tip, it works OK for converted emails.

    First of all my objective is to pre-populate all Outlook folders with known data in order to check that a backup/restore is working correctly.

    My code to change a email to a note follows.  However, it's only partially operational, since all the MapiPropertyType.Long values end up in the final note as PT_I8 rather than PT_LONG.

     

    EmailMessage message = new EmailMessage

    (exchangeService);

    message.ItemClass =

    "IPM.StickyNote"

    ;

     

    Guid guid = new Guid("0006200E-0000-0000-C000-000000000046"

    );

    message.SetExtendedProperty(

    new ExtendedPropertyDefinition(guid, 0x8B00, MapiPropertyType.Long), 1);

    // colour

    message.SetExtendedProperty(

    new ExtendedPropertyDefinition(guid, 0x8B02, MapiPropertyType.Long), 200);

    // width

    message.SetExtendedProperty(

    new ExtendedPropertyDefinition(guid, 0x8B03, MapiPropertyType.Long), 166);

    // height

    message.SetExtendedProperty(

    new ExtendedPropertyDefinition(guid, 0x8B04, MapiPropertyType.Long), 200);

    // left

    message.SetExtendedProperty(

    new ExtendedPropertyDefinition(guid, 0x8B05, MapiPropertyType.Long), 200);

    // top

    message.Subject =

    "Test"

    ;

    message.Body =

    "Test of conversion from Email to note"

    ;

     

    try

    {

    message.Save(

    WellKnownFolderName

    .Notes);

    }

     

    catch (Exception

    e)

    {

     

    String

    msg = e.Message;

    }

    

    Any further advice would be more than welcome.

    Best Regards,

    Kevin.

    Saturday, June 4, 2011 6:33 AM
  • EWS datatypes don't map directly to those you see in a mapi editor you should be using Interger datatype eg try

          EmailMessage message = new EmailMessage(service);
          message.ItemClass = "IPM.StickyNote";
          Guid guid = new Guid("0006200E-0000-0000-C000-000000000046");
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B00, MapiPropertyType.Integer), 1);
          // colour
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B02, MapiPropertyType.Integer), 200);
          // width
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B03, MapiPropertyType.Integer), 166);
          // height
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B04, MapiPropertyType.Integer), 200);
          // left
          message.SetExtendedProperty(new ExtendedPropertyDefinition(guid, 0x8B05, MapiPropertyType.Integer), 200);
          // top
          message.Subject = "Test Note" ;
          message.Body = new MessageBody("Test of conversion from Email to note"); 
          message.Save(WellKnownFolderName.Notes);
    

    Cheers
    Glen

     

     

    Monday, June 6, 2011 11:36 AM
  • Hi Glen,

    Thank you very much for that.  It works well now.

    Now if only I could get the dummy 'Sync Issues' working too :-)

     

    Best Regards,

    Kevin.

    Monday, June 6, 2011 8:27 PM