Mandrill: how to set Reply-To?

Oct 9, 2012 at 1:51 PM
Edited Oct 9, 2012 at 2:23 PM

Seems like this has to be set in the headers? But I'm not sure how to manipulate this dictionary:

message.Headers.Value["Reply-To"] = "emailaddr"; ?

What is message.Headers.Item ?

Also, message.Headers is null when I create a message. How to instantiate and use it?

Thanks

Coordinator
Oct 9, 2012 at 6:42 PM

Here is an example (C#):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MailChimp;
using MailChimp.Types;
using MN = MailChimp.Types.Mandrill;

namespace SpamService
{
    public class Spammer
    {
        public static void Main(string[] args)
        {
            var api = new MandrillApi("key");
            
            var message = new MN.Messages.Message();
            message.Subject = "Test";
            message.FromEmail = "xxx@xxx.com";
            message.FromName = "xxx";
            message.To = new [] { new MN.Messages.Recipient("test@test.com", "test") };
            
            //... set other fields ...

            // "Reply-To" a single email
            message.Headers = new MCDict<MN.Messages.Header> { 
                { "Reply-To", "xxx@xxx.com" },
                { "X-Mailer", "spam service :)" }
            };
            // "Reply-To" multiple emails
            message.Headers = new MCDict<MN.Messages.Header> { 
                { "Reply-To", new [] { "xxx1@xxx.com", "xxx2@xxx.com" } },
                { "X-Mailer", "spam service :)" }
            };

            try {
                api.Send(message);
            }
            catch (Exception ex) {
                // Write to log ...
            }
        }
    }
}

Oct 9, 2012 at 6:53 PM

Thanks a lot.

Would be great if we could avoid the "new MCDict<MN.Messages.Header>" syntax.