Secure Exchanges SDK Documentation
Search Results for

    Show / Hide Table of Contents

    Multi-Recipient Sending

    This guide explains how to send a message to multiple recipients.

    Concept

    With MutliRecipientArgs, you can send the same message to multiple people. Each recipient receives their own secure link.

    Quick Example

    var recipients = new List<RecipientInfo>
    {
        new RecipientInfo { Email = "recipient1@example.com" },
        new RecipientInfo { Email = "recipient2@example.com" },
        new RecipientInfo { Email = "recipient3@example.com" }
    };
    
    Uri endpoint = new Uri("https://www.secure-exchanges.com/_api/0217/0217.asmx");
    
    var args = new MutliRecipientArgs(
        endpoint, serial, apiUser, apiPassword,
        recipients,
        "Message for everyone",
        "Subject",
        null, null, SendMethodEnum.onlyEmail,
        false, true, true, "en-CA", 5, 1440
    );
    
    var response = MessageHelper.MultiRecipientMessage(args);
    
    // Each recipient has their own response
    foreach (var recipientAnswer in response.RecipientsAnswer)
    {
        Console.WriteLine($"URL: {recipientAnswer.Answer.URL}");
    }
    

    Complete Example: HR Information Broadcast

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using SecureExchangesSDK.Helpers;
    using SecureExchangesSDK.Models.Args;
    using SecureExchangesSDK.Models.Entity;
    using SecureExchangesSDK.SecureExchanges;
    
    public class HRCommunicationService
    {
        private readonly Guid _serial;
        private readonly Guid _apiUser;
        private readonly Guid _apiPassword;
    
        public HRCommunicationService(Guid serial, Guid apiUser, Guid apiPassword)
        {
            _serial = serial;
            _apiUser = apiUser;
            _apiPassword = apiPassword;
        }
    
        /// <summary>
        /// Sends a confidential HR bulletin to all employees
        /// </summary>
        public BroadcastResult SendHRBulletin(
            List<Employee> employees,
            string subject,
            string htmlContent,
            List<string> attachmentPaths = null)
        {
            // Convert employees to RecipientInfo
            var recipients = employees
                .Where(e => !string.IsNullOrEmpty(e.Email))
                .Select(e => new RecipientInfo { Email = e.Email })
                .ToList();
    
            if (!recipients.Any())
                return new BroadcastResult { Success = false, Error = "No valid recipients" };
    
            // Configuration
            Uri endpoint = new Uri("https://www.secure-exchanges.com/_api/0217/0217.asmx");
    
            var args = new MutliRecipientArgs(
                endpoint,
                _serial,
                _apiUser,
                _apiPassword,
                recipients,
                htmlContent,
                subject,
                password: null,
                filesList: null,
                SendMethodEnum.onlyEmail,
                sendByMyOwnSMTPServer: false,
                showSubject: true,
                getNotify: false,  // No notification for bulk sends
                culture: "en-CA",
                maxOpeningTime: 10,
                expirationMinutes: 43200  // 30 days
            );
    
            if (attachmentPaths != null)
                args.FilesPath = attachmentPaths;
    
            // Send
            var response = MessageHelper.MultiRecipientMessage(args);
    
            if (response.Status == 200)
            {
                var results = new List<RecipientResult>();
    
                for (int i = 0; i < response.RecipientsAnswer.Count; i++)
                {
                    var answer = response.RecipientsAnswer[i].Answer;
                    results.Add(new RecipientResult
                    {
                        Email = recipients[i].Email,
                        Success = answer.Status == 200,
                        MessageUrl = answer.URL,
                        Error = answer.Status != 200 ? "Send failed" : null
                    });
                }
    
                return new BroadcastResult
                {
                    Success = true,
                    TotalRecipients = recipients.Count,
                    SuccessCount = results.Count(r => r.Success),
                    FailedCount = results.Count(r => !r.Success),
                    RecipientResults = results
                };
            }
    
            return new BroadcastResult
            {
                Success = false,
                Error = response.Data
            };
        }
    }
    
    public class Employee
    {
        public string Email { get; set; }
        public string Name { get; set; }
        public string Department { get; set; }
    }
    
    public class BroadcastResult
    {
        public bool Success { get; set; }
        public string Error { get; set; }
        public int TotalRecipients { get; set; }
        public int SuccessCount { get; set; }
        public int FailedCount { get; set; }
        public List<RecipientResult> RecipientResults { get; set; }
    }
    
    public class RecipientResult
    {
        public string Email { get; set; }
        public bool Success { get; set; }
        public string MessageUrl { get; set; }
        public string Error { get; set; }
    }
    

    Best Practices

    • Limit the number of recipients per send (recommended: max 100)
    • Disable notifications (getNotify: false) for bulk sends
    • Handle individual errors - some recipients may fail

    See Also

    • First Message
    • Messages with Files
    In this article
    Back to top Secure Exchanges Inc. - Documentation