Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to generate and send e-mails (bulk mail) while iterating through datasource records

$
0
0

In some scenarios, you need to generate e-mail letters and send them while iterating through some datasource records.

Let's consider the following scenario. We have a master-detail database. A master table contains information about customers whom we need to send letters. A detail table contains information to generate letters.


To generate and send letters, we need to perform the following actions while iterating through the data source:

1. Create a filtered view from the child table based on the customer's ID.

2. Use this view as a SnapControl's mail merge data source.

3. Iterate through this view records.

4. Perform the mail-merge operation.

5. Generate an e-mail letter based on the SnapControl's document as demonstrated in the following example: How to export the RichEditControl document into an Outlook mail item

You may notice only one issue. The content of some letters will be generated incorrectly.

This occurs since the loading of the mail template into the SnapControl is executed asynchronously and can require more time than iterating to the next datasource record.

When a document is completely loaded into the SnapControl (or RichEditControl), the DocumentLoaded event is raised.


To avoid the issue with an incorrectly generated content of a letter, you need to send letters in the DocumentLoaded event handler.

We recommend saving generated letters in a temporary folder while iterating through datasource records.

After all letters are saved, load these files and send the letters synchronously in the SnapControl.DocumentLoaded event handler.

This example demonstrates this approach in action.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>