I want to send a message using Mandrill.I need the following code to do this:
Send the same message to all recipient without Each one of them see the address of the other recipient.
I used the following code :
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
string[] toResult = to.Split(new Char[] { ';' });
foreach (string s in toResult)
{
if (s != null && !s.Trim().Equals("") && !string.IsNullOrEmpty(s))
{
message.Bcc.Add(s);
}
}
if (!cc.Equals(""))
{
string[] ccResult = cc.Split(new Char[] { ';' });
foreach (string s in ccResult)
{
message.CC.Add(s);
}
}
if (!cci.Equals(""))
{
string[] cciResult = cci.Split(new Char[] { ';' });
foreach (string s in cciResult)
{
message.Bcc.Add(s);
}
}
message.Subject = subject;
message.From = new System.Net.Mail.MailAddress(from, from);
message.IsBodyHtml = true;
message.Body = "<html><body>" + body + "</body></html>";
message.BodyEncoding = System.Text.Encoding.UTF8;
System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
(System.Text.RegularExpressions.Regex.Replace(body, @"<(.|\n)*?>", string.Empty), System.Text.Encoding.UTF8, "text/plain");
System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(body, System.Text.Encoding.UTF8, "text/html");
message.AlternateViews.Add(plainView);
message.AlternateViews.Add(htmlView);
message.Priority = System.Net.Mail.MailPriority.Normal;
smtp.Host = smtpH;
bool ssl = false;
if (useSSL.Equals("true"))
ssl = true;
if (ssl)
{
smtp.EnableSsl = true;
}
else
{
smtp.EnableSsl = false;
}
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(userName, password);
smtp.Port = Convert.ToInt32(port);
message.Headers.Add("Message-Id", String.Concat("<", DateTime.Now.ToString("yyMMdd"), ".",
DateTime.Now.ToString("HHmmss"), "@" + from.Split('@')[1].ToString() + ">"));
smtp.Send(message);
As you can see in the code snippet above, I added all the emails in the Bcc collection, but it does not work.
Does anyone have any idea about this problem.
If people are still seeing each other's email address, you'll probably want to go to the Sending Defaults page in your account and disable the option to expose recipients to one another. Otherwise, you can add a custom SMTP header to turn that option off, but it sounds like you probably don't want that on by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With