Sample: Manage lists and send transactional or commercial email
This sample code is for Microsoft Dynamics Marketing. The sample code can be found in the following location after you download and install the Microsoft Dynamics Marketing SDK:
Samples\CS\EmailMessageSample
Requirements
Download and install the Microsoft Dynamics Marketing SDK.
Enable the SDK gateway and assign permissions to queues. More information: Authorize queues
Follow the instructions provided in the Quick start with sample code to install, build, and run the sample.
Note
This sample works with your live production data. It may create contact objects in your Microsoft Dynamics Marketing and Microsoft Dynamics CRM environments. In addition, it will send emails to the designated recipients.
Tip
- You should allocate some email addresses that actually exist as a test audience, and then write scenario tests that run against the test audience. Create a marketing list specifically for testing mails and create test contacts with email addresses you control as an audience for testing your email marketing messages and SDK integration.
- Use email marketing message testing functions to determine if the email messages are formatted correctly before sending the email messages.
Demonstrates
This sample demonstrates how to retrieve and send email marketing emails that are marked “Send Externally”, and send commercial email marketing messages using Dynamics Marketing. Additionally, this sample also demonstrates how to set and retrieve contact permissions for a single or multiple email addresses, retrieve list of email addresses for which contact permissions are missing, and get or set email hard bounces to be processed for a contact.
Example
Troubleshooting
If the response isn’t received in time, you’ll get the following error message:
“The request has been sent but the response was not received. You may want to wait a few more seconds and try to receive the response again or try increasing the ResponseMessageTimeout in client.cs. “
Some of the possible reasons why the response isn’t received:
The server took longer than expected to process this response. Try selecting Option A, to see the response. If this issue occurs frequently, consider changing the value of the ResponseMessageTimeout constant in your client.cs file.
Either your client is looking at the wrong response queue, or Microsoft Dynamics Marketing is unable to write to the response queue due to a configuration error. To learn how to set up your queues correctly, see Getting started with the SDK.
If you don’t receive a response immediately, try using the Get all responses for this session option. Sometimes a response may take longer than the default time-out period.
If you never receive the response, make sure your request and response queue names and namespace matches the details you provided on Home > Settings > Administrator > Integration Options. More information: Site configuration and integration settings.
If you’re not seeing any emails when using RetrieveEmailMessagesRequest, make sure that you are creating emails with the Send Externally option checked.
If your email isn’t being sent, debug the ProcessSendEmailMessageResponse response handler and check the Message property. The message will contain the validation error, if any.
If you send email to an external mail ID (email message ID) using the command option Send email message by email ID, you get the following error message:
“Validation of email message failed for Send. Please check input.”
For the specified email address that you’re using, there is no email created with the Send Externally option checked. You must first create the email with the Send Externally option checked in Microsoft Dynamics Marketing, and then get the external ID for email message either from the Retrieve action or on the Home > Marketing Execution > Email Marketing > Messages by clicking on the Customize column icon and selecting External ID from the list.
See Also
Tasks
Reference
Microsoft.Dynamics.Marketing.SDK.Common
Microsoft.Dynamics.Marketing.SDK.Messages
Microsoft.Dynamics.Marketing.SDK.Messages.EmailMessage
Microsoft.Dynamics.Marketing.SDK.Model
Concepts
Developer overview of Microsoft Dynamics Marketing
Introduction to marketing entities
Manage lists and send transactional or commercial email
Getting started with the SDK
Sample code
Assembly included in the Microsoft Dynamics Marketing SDK
Other Resources
Programming reference for Microsoft Dynamics Marketing
Send comments about this topic to Microsoft.
© 2015 Microsoft. All rights reserved.