Create and send an email as a delegate using EWS Managed API RRS feed

  • Question

  • Hi All,

    I would like to create and send an email as a delegate using EWS Managed API for that i have crated one user as a delegate to that mailbox owner.

    after adding user as delegate, when i try to create an email The EmailMessage class taking only FolderId as parameter but not taking Mailbox object as parameter. But in web reference they said that EmailMessage taking FolderId and Mailbox object as parameter.

    EmailMessage message = new EmailMessage(service); message.Subject = "Company Soccer Team"; message.Body = "Are you interested in joining?"; message.ToRecipients.Add(""); message.Save(new FolderId(WellKnownFolderName.Drafts, new Mailbox("")));

    could you people please help me on this?



    Saturday, April 18, 2015 12:37 PM


All replies

  • >> would like to create and send an email as a delegate using EWS Managed API for that i have crated one user as a delegate to that mailbox owner.

    How have you delegated access to the Mailbox (eg vai outlook delegate or Add-MailboxPermissions) ? and do you want to SendAs the user or Send on Behalf of the user ?

    If you have granted access via Outlook Delegates then you would only be able to SendOnBehalf of the user and you also wouldn't be granted access to the users drafts folder so your code would fail their. If you have used Add-MailboxPermission then you won't have either SendOnBehalf or SendAs permission so you should be able to save a message to the drafts folder but you won't be able to send anything until you assign SendAs Rights

    Eg if your getting an error message you should also post the error message as your question is not that clear.


    Monday, April 20, 2015 3:40 AM
  • Thanks for reply glen.

    I have added delegate using Add-MailboxPermissions. Now i am able to save an email in mailbox owner drafts folder.


     I have a one more question.(I am using EWS Managed API).

    I(owner) have shared my calendar(eg. samplecalenderfolder) with another user(delegate) (i.e.,he is the delegate of my mailbox) and i have given only permission to the this folder(samplecalenderfolder) only and the permission level is Reviewer.

    if i login with user(i.e.delegate) i am not able to get the shared calendar folders(i.e.,samplecalenderfolder) that what i a have shared.

    below is the code snippet i am using to get the calendar folders.

    Folder folder = Folder.Bind(service,WellKnownFolderName.Calendar);

    FindFoldersResults addtionalFolders = service.FindFolders(folder.Id, new FolderView(10));

    could you please tell us how to get the shared calendar folders.



    Monday, April 20, 2015 1:03 PM
  • Tuesday, April 21, 2015 4:40 AM
  • Glen,

    i followed this reference but

    still i am not getting shared calendar folders. Any Ideas?



    Tuesday, April 21, 2015 7:14 AM
  • What happens ? do you get an error ?

    That code reads the shortcuts from Outlook do the shortcuts exist in the first place ? eg if you logon to the Mailbox using Outlook or OWA do you see that Calendar you want to connect to in other Calendar folders. If you don't you will need to at least open the folder once in one of the clients for the shortcut to be created.


    Wednesday, April 22, 2015 4:48 AM

  • Thank you very much Glen. It is giving the shared folder information as a EmailMessage.

    Actually i have shared a calendar using outlook. Outlook sent a sharing message to the invitee. But invitee does not open that calendar that is why it is not added to the Other Calendars or Shared Calendars folder.

    If the invitee open the calendar it is added to the shared calendar folder. After it is added to the Shared Calendar Folder, i mentioned the Share Calendar instead of Other Calenders now it is giving the Shared Calendar folder information as a EmailMessage.

    SearchFilter cntSearch = new SearchFilter.IsEqualTo(PidTagWlinkGroupName, "Shared Calendars");

    In my company we have been send and receiveing emails, meeting mails etc everything using EWS Managed API.

    Glen Is it possible to share a calendar using EWS Managed API (using delegates)?



    Wednesday, April 22, 2015 6:12 AM
  • >> It is giving the shared folder information as a EmailMessage

    Sorry I don't really understand what your asking maybe some screenshots would help. Are you talking about ics calendars ?

    >> Glen Is it possible to share a calendar using EWS Managed API (using delegates)?

    Yes just use the Delegate operations


    Thursday, April 23, 2015 6:55 AM
  • Glen,

    i have added one user as a delegate to my mail box and i have created one calendar folder and given permission to that calendar folder. But if log in with another user i am unable to get the caledar folder using theis method:

    below is the code snippet what i did to share a calendar:

    ExchangeService service = GetExchangeService();
                    Mailbox ownerMailbox = new Mailbox(ownerAddress);

    PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, FolderSchema.Permissions);

                    FolderPermission fldperm = new FolderPermission(delegateEmailAddress, folderPermission);

                    Folder folder = Folder.Bind(service, folderId, propSet);



    am i missing something else?



    Friday, April 24, 2015 12:58 PM
  • The Delegate operations only affect the default calendar for the Mailbox. User created calendar folders as far as I know you would have to share them vai Outlook Sharing request you could automate it with the OOM EWS doesn't have any operations to assist in creating those type of sharing requests.


    Friday, April 24, 2015 11:03 PM