We are using the XRM SDK to distribute emails to our customers.  Each email can be different so we using the Bulk Request Messages to push the created email records up into Dynamics - ExecuteMultipleRequest and ExecuteMultipleResponse.

I should not, we have about 50,000 emails to send out, hence the bulk API so we don't get push back from the API limits of Dynamics.

This works fine for creating the email in a Draft state but we cannot get the emails to "send" reliably once up there.  We have tried the following implementations;

  1. Created a workflow when new email records are created, their state is set to SENT and they are sent out.  This didn't work as what we saw happen was all the workflows going into a pending resource state because they are all trying to execute at the same time (so 900 emails created at around the same time by the bulk API then queues up 900 workflows which all block each other).
  2. I have tried submitting SendEmailRequest via the Bulk API, but this throws back errors at us about timeout states and the API not responding.

Here is the code I have for #2

SendEmailRequest sendEmailRequest = new SendEmailRequest
EmailId = draftEmail.Id,
TrackingToken = "",
IssueSend = false


bulkRequest = new ExecuteMultipleRequest()
Settings = new ExecuteMultipleSettings()
ContinueOnError = true,
ReturnResponses = false
Requests = new OrganizationRequestCollection()

It's pretty simple and straigthforward.

Any ideas on how to mark these emails as sent in the system and get them out of draft state?

This is a process we run at least once a month.

Thanks - Greg