user3644795
user3644795

Reputation:

Save sent mail to user's sent items folder

I use the EWS-Java-API.

I have a system where "admin mail" is logged in. Then I have the users with their own mails, sending mails to buyers or something else. Right now when a user send a mail, it's saving the mail in the admins "SENT ITEMS folder", but I want them to get saved in the user's folder.

Mailbox mb = new Mailbox();
mb.setAddress(from.trim());
FolderId SentFolderForUser = new FolderId(WellKnownFolderName.SentItems, mb);
emailMessage.sendAndSaveCopy(SentFolderForUser);

Caused by:

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: The specified object was not found in the store., The process failed to get the correct properties.

Is there a better way to do this?

Upvotes: 0

Views: 805

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

That error means "admin mail" doesn't have rights to the SentItems folder of the user in mb (you can test this simply by trying to bind to the Folder first)

Folder SendItems = Folder.Bind(service, SentFolderForUser);

You need to give the "admin mail" user access to the Mailbox via Add-Mailboxpermission https://technet.microsoft.com/en-us/library/bb124097(v=exchg.160).aspx .

Cheers Glen

Upvotes: 1

Related Questions