smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
582 stars 178 forks source link

How do you add multiple addresses to the MailAddressCollection CC #97

Closed doug-coates closed 11 years ago

doug-coates commented 11 years ago

We are using distribution list for groups but is there a way to add multiple addresses to the MailAddressCollection CC I'm using the following function to load the MVCMailerMessage. Can you provide a example how to load a list of addresses into the MailAddressCollection CC

public virtual MvcMailMessage InternalReview(Email e) { ViewData.Model = e;

        return Populate(x =>
        {
            x.Subject = "List Added";
            x.ViewName = "InternalReview";
            x.To.Add(e.to);
            x.CC.Add(e.co);
        });

}

Thanks Doug

smsohan commented 11 years ago

You can keep adding more addresses by x.To.Add or x.CC.Add

doug-coates commented 11 years ago

I’m passing in a email class that has string[] of recipients… Is there a way of adding a foreach loop from an array of strings

foreach (string address in recipient) { x.CC.Add(address); }

Douglas Coates Application Architect t: 616.393.1509 | c: 616.666.6842 | f: 616.393.3584 | e: doug.coates@haworth.com One Haworth Center, Holland, MI 49423-9576 USA | 616.393.3000 haworth.com

[cid:image001.png@01CE524D.35C7F7A0]

Notice of Confidentiality: This message and any attachments are confidential. If you are not the intended recipient, please do not read or distribute it. Alert the sender by reply email and delete this message immediately.

From: SM Sohan [mailto:notifications@github.com] Sent: Thursday, May 16, 2013 3:26 PM To: smsohan/MvcMailer Cc: Doug Coates Subject: Re: [MvcMailer] How do you add multiple addresses to the MailAddressCollection CC (#97)

You can keep adding more addresses by x.To.Add or x.CC.Add

— Reply to this email directly or view it on GitHubhttps://github.com/smsohan/MvcMailer/issues/97#issuecomment-18023430.

smsohan commented 11 years ago

You can do something like this:

recipients.ForEach(recipient => x.CC.Add(recipient))