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

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("sadie@contoso.com"); message.Save(new FolderId(WellKnownFolderName.Drafts, new Mailbox("primary@contoso.com")));

https://msdn.microsoft.com/EN-US/library/office/dn641963(v=exchg.150).aspx#bk_createewsma

could you people please help me on this?

Thanks

Naresh


April 18th, 2015 8:40am

>> 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 https://technet.microsoft.com/en-us/library/bb676368(v=exchg.141).aspx

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

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
April 19th, 2015 11:41pm

Thanks for reply glen.

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

Glen,

 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.

Thanks

Naresh

April 20th, 2015 9:07am

Have a look at my answer in http://stackoverflow.com/questions/23766747/ews-access-all-shared-calendars

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
April 21st, 2015 12:45am

Glen,

i followed this  http://stackoverflow.com/questions/23766747/ews-access-all-shared-calendars reference but

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

THanks

Naresh

April 21st, 2015 3:19am

Glen,

i followed this  http://stackoverflow.com/questions/23766747/ews-access-all-shared-calendars reference but

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

THanks

Naresh

Free Windows Admin Tool Kit Click here and download it now
April 21st, 2015 7:14am

Glen,

i followed this  http://stackoverflow.com/questions/23766747/ews-access-all-shared-calendars reference but

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

THanks

Naresh

April 21st, 2015 7:14am

Glen,

i followed this  http://stackoverflow.com/questions/23766747/ews-access-all-shared-calendars reference but

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

THanks

Naresh

Free Windows Admin Tool Kit Click here and download it now
April 21st, 2015 7:14am

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.

Cheers
Glen 

April 22nd, 2015 12:49am


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)?

Thanks

Naresh

Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 2:13am

>> 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 https://msdn.microsoft.com/en-us/library/office/dn641959(v=exchg.150).aspx

Cheers
Glen

April 23rd, 2015 2:56am

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:

http://stackoverflow.com/questions/23766747/ews-access-all-shared-calendars

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);

                folder.Permissions.Add(fldperm);

                folder.Update();

am i missing something else?

Thanks

Naresh

Free Windows Admin Tool Kit Click here and download it now
April 24th, 2015 9:00am

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 https://msdn.microsoft.com/en-us/library/office/ff865852.aspx. EWS doesn't have any operations to assist in creating those type of sharing requests.

Cheers
Glen

April 24th, 2015 7:05pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics