WFFM Send Message BCC and CC issue


WFFM Send Message BCC and CC issue 

If you use the Send Message action in web form marketer, and when we  tried to set multiple contact in the BCC value separated with ";" it keep just send the email to the last contact.

This is a known issue in sitecore but they stop support fixes to this issue in old version
So what if I have old version such as 7.1 update 1 we can resolved this issue with below solution.

Overwrite the GetMail method as below

namespace YourNamespace.Business.WFFM.Pipelines
{
class ProcessMessage
{
public ProcessMessage()
{
}
private MailMessage GetMail(ProcessMessageArgs args)
{
MailMessage mail = new MailMessage(args.From.Replace(";", ","), args.To.Replace(";", ",").ToString(), args.Subject.ToString(), args.Mail.ToString())
{
IsBodyHtml = args.IsBodyHtml
};
if (args.CC.Length > 0)
{
char[] separator = new char[] { ',' };
foreach (string str in args.CC.Replace(";", ",").ToString().Split(separator))
{
mail.CC.Add(new MailAddress(str));
}
}
if (args.BCC.Length > 0)
{
char[] chArray2 = new char[] { ',' };
foreach (string str2 in args.BCC.Replace(";", ",").ToString().Split(chArray2))
{
mail.Bcc.Add(new MailAddress(str2));
}
}
args.Attachments.ForEach(delegate (Attachment attachment) {
mail.Attachments.Add(attachment);
});
return mail;
}
public void SendEmail(ProcessMessageArgs args)
{
SmtpClient client = new SmtpClient(args.Host)
{
EnableSsl = args.EnableSsl
};
if (args.Port != 0)
{
client.Port = args.Port;
}
client.Credentials = args.Credentials;
client.Send(this.GetMail(args));
}
}
}


And use below custom pipeline configurations  


<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<processMessage>
<processor type="YourNamespace.Business.WFFM.Pipelines.ProcessMessage, YourNamespace.Business" method="SendEmail" patch:instead="processor[@method='SendEmail']" />
</processMessage>
</pipelines>
</sitecore>
</configuration>
view raw Pipline.config hosted with ❤ by GitHub



Comments

Popular posts from this blog

Sitecore SaaS Product

SIF Certificate Root expired

Sitecore 9 Update 2 Installation Guide Step by step