Dynamicweb 8 Documentation
Message Class
Members  Example 

A message object used for EmailMessaging.
Syntax
'Declaration
 
Public Class Message 
public class Message 
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
Inheritance Hierarchy

System.Object
   Dynamicweb.EmailMessaging.Message

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

Message Members
Dynamicweb.EmailMessaging Namespace

Send Feedback