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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Comments
Post a Comment