GemBox.Email
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    MailMerge Class

    Namespace:
    GemBox.Email
    Assembly:
    GemBox.Email.dll

    Contains methods for mail merge; creating multiple messages based on a template message and variable data.

    • C#
    • VB.NET
    public static class MailMerge
    Public Module MailMerge
    Inheritance:
    System.Object
    MailMerge

    Methods

    Merge(MailMessage, IMailMergeDataSource)

    Generates a collection of mail messages based on the specified template and populated with provided data.

    • C#
    • VB.NET
    public static ReadOnlyCollection<MailMessage> Merge(MailMessage template, IMailMergeDataSource dataSource)
    Public Shared Function Merge(template As MailMessage, dataSource As IMailMergeDataSource) As ReadOnlyCollection(Of MailMessage)
    Parameters
    template
    MailMessage

    The template mail message.

    dataSource
    IMailMergeDataSource

    The data source.

    Returns
    System.Collections.ObjectModel.ReadOnlyCollection<MailMessage>

    A read-only collection of mail messages based on the specified template and populated with provided data.

    Remarks

    Method returns a collection of messages based on the specified template. Strings starting and ending with delimiter (%) are replaced with values from provided data source. These variables can be used in: Subject, BodyText and BodyHtml properties.

    note

    Data source must contain value named 'To' which represents receiver mail address. Other predefined value names are: 'Cc', 'Bcc' and 'ReplyTo'.

    Exceptions
    System.ArgumentNullException

    Template is null or Data source is null

    Merge(MailMessage, DataTable)

    Generates a collection of mail messages based on the specified template and populated with provided data.

    • C#
    • VB.NET
    public static ReadOnlyCollection<MailMessage> Merge(MailMessage template, DataTable data)
    Public Shared Function Merge(template As MailMessage, data As DataTable) As ReadOnlyCollection(Of MailMessage)
    Parameters
    template
    MailMessage

    The template mail message.

    data
    System.Data.DataTable

    The data source.

    Returns
    System.Collections.ObjectModel.ReadOnlyCollection<MailMessage>

    A read-only collection of mail messages based on the specified template and populated with provided data.

    Remarks

    Method returns a collection of messages based on the specified template. Strings starting and ending with delimiter (%) are replaced with values from provided data source. These variables can be used in: Subject, BodyText and BodyHtml properties.

    note

    Data source must contain value named 'To' which represents receiver mail address. Other predefined value names are: 'Cc', 'Bcc' and 'ReplyTo'.

    Exceptions
    System.ArgumentNullException

    Template is null or Data source is null

    Merge<T>(MailMessage, IEnumerable<T>)

    Generates a collection of mail messages based on the specified template and populated with provided data.

    • C#
    • VB.NET
    public static ReadOnlyCollection<MailMessage> Merge<T>(MailMessage template, IEnumerable<T> items)
    Public Shared Function Merge(Of T)(template As MailMessage, items As IEnumerable(Of T)) As ReadOnlyCollection(Of MailMessage)
    Parameters
    template
    MailMessage

    The template mail message.

    items
    System.Collections.Generic.IEnumerable<T>

    The generic list of objects used as data source.

    Returns
    System.Collections.ObjectModel.ReadOnlyCollection<MailMessage>

    A read-only collection of mail messages based on the specified template and populated with provided data.

    Type Parameters
    T

    The type of data elements in the collection.

    Remarks

    Method returns a collection of messages based on the specified template. Strings starting and ending with delimiter (%) are replaced with values from provided data source. These variables can be used in: Subject, BodyText and BodyHtml properties.

    note

    Data source must contain value named 'To' which represents receiver mail address. Other predefined value names are: 'Cc', 'Bcc' and 'ReplyTo'.

    Exceptions
    System.ArgumentNullException

    Template is null or Data source is null

    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.