none
SendAndSaveCopy fails with ErrorMissingEmailAddress when connecting as user without a mailbox and sending email with attachment RRS feed

  • Question

  • I'm using C# EWS Managed API and when I try to send an email using SendAndSaveCopy() with an attachment it fails if I'm connecting using windows auth as a user without a mailbox. I'm specifying the FolderId to save to so I'd expect it to work, but I get an error with code ErrorMissingEmailAddress: When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.

    Looking at the EWS trace I see the call to SendAndSaveCopy() is first issuing a call with <m:CreateItem MessageDisposition="SaveOnly"> and that fails. I'm connecting using windows authentication using a service account, which doesn't have a mailbox, and then interacting with a particular mailbox. Using windows auth and a service account is a customer requirement in their environment. If instead I connect using username & password authentication, in my test environment, I SendAndSaveCopy() issues two EWS calls: the first has <m:CreateItem MessageDisposition="SaveOnly"> and does not specify a SavedItemFolderId. It gets a response with the ItemId of the message and attachments, and the second call has <m:SendItem SaveItemToFolder="true"> and includes a <m:SavedItemFolderId> of the SentItems folder. 

    Is this a known problem with SendAndSaveCopy()? How should I call the EWS Managed API to correctly send an email with an attachment and save it to the SentItems of a particular mailbox? 

    If I'm to call CreateItem() and then call SendItem(), should I tell CreateItem() to save to Drafts or to Sent Items? I see this slightly cryptic message in the SendItem docs "If an item in the Sent Items folder is sent, the sent item is deleted and a copy of it is put in the Sent Items folder." My concern with saving to SentItems is if the subsequent call to SendItem() fails I'll be left with an item in Sent Items that appears to have been sent but actually hasn't. If I instead save to Drafts is the item automatically removed from there when I call SendItem() and tell it to save to the SentItems folder? 

    Thanks for any pointers,

    Rory

    I also posted this question on Stack Overflow.

    Tuesday, December 22, 2015 1:16 AM