Dynamicweb 8 Documentation
MessagingHandler Constructor(Message,RecipientCollection)
Example 

The Message to handle.
The recipients to handle.
Creates a new instance of the messaging handler. This constructor should only be used when starting a new send process, not when resuming.
Syntax
'Declaration
 
Public Function New( _ 
   ByVal message As Message, _ 
   ByVal recipients As RecipientCollection _ 
)
public MessagingHandler( 
   Message message,
   RecipientCollection recipients 
)

Parameters

message
The Message to handle.
recipients
The recipients to handle.
Example
Working with message, recipients and sending them.Working with message, recipients and sending them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dynamicweb.Examples.CSharp.EmailMessaging
{
    class MessageRecipientSendingSample
    {
        public void SendMessage()
        {
            //Create a recipient collection and fill it with 100 recipients.
            var recipientCollection = new Dynamicweb.EmailMessaging.RecipientCollection();
            for (var i = 0; i < 100; i++)
            {
                var recipient = new Dynamicweb.EmailMessaging.Recipient();
                recipient.Name = "Test" + i;
                recipient.EmailAddress = String.Format("test{0}@testdomain.tld", i);
                recipientCollection.Add(recipient);
            }

            //Create a message that will be sent.
            var message = new Dynamicweb.EmailMessaging.Message();
            message.Subject = "This is a test email";
            message.HtmlBody = String.Format("<h1>Hello <!--@{0}--></h1><br /><p>This is a test</p>", Dynamicweb.EmailMessaging.Constants.TAG_RECIPIENT_NAME);
            message.SenderEmail = "webshop@mydomain.tld";
            message.SenderName = "Test Webshop";

            //Instanciate the MessagingHandler, which will start the process.
            //Using the CallbackHandler is reviewed in another example.
            var handler = new Dynamicweb.EmailMessaging.MessagingHandler(message, recipientCollection);
            var processStarted = handler.Process();

            //The boolean 'processStarted' indicated whether the process of preprocessing, merging and sending was started.
            //This process is run asynchronously in multiple threads to increase performance.
            if (!processStarted)
                throw new Exception("Sending could not be started");
        }
    }
}
Public Class MessageRecipientSendingSample

    Public Sub SendMessage()
        'Create a recipient collection and fill it with 100 recipients.
        Dim recipientCollection As New Global.Dynamicweb.EmailMessaging.RecipientCollection()
        For i As Integer = 0 To 99
            Dim recipient As New Global.Dynamicweb.EmailMessaging.Recipient()
            recipient.Name = "Test" & i
            recipient.EmailAddress = String.Format("test{0}@testdomain.tld", i)
            recipientCollection.Add(recipient)
        Next

        'Create a message that will be sent.
        Dim message As New Global.Dynamicweb.EmailMessaging.Message()
        message.Subject = "This is a test email"
        message.HtmlBody = String.Format("<h1>Hello <!--@{0}--></h1><br /><p>This is a test</p>", Global.Dynamicweb.EmailMessaging.Constants.TAG_RECIPIENT_NAME)
        message.SenderEmail = "webshop@mydomain.tld"
        message.SenderName = "Test Webshop"

        'Instanciate the MessagingHandler, which will start the process.
        'Using the CallbackHandler is reviewed in another example.
        Dim handler As New Global.Dynamicweb.EmailMessaging.MessagingHandler(message, recipientCollection)
        Dim processStarted = handler.Process()

        'The boolean 'processStarted' indicated whether the process of preprocessing, merging and sending was started.
        'This process is run asynchronously in multiple threads to increase performance.
        If Not processStarted Then
            Throw New Exception("Sending could not be started")
        End If
    End Sub
End Class
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

MessagingHandler Class
MessagingHandler Members
Overload List

Send Feedback