public MailMessage CreateMessage(StringBuilder builder, ISmtpSession session) { var message = new MessageParser().Parse(builder.ToString()); // Any recipients that are registered but haven't been used are blind copies session .Recipients .Where(x => !message.To.Any(y => y.Address == x) && !message.CC.Any(y => y.Address == x)) .Each(x => message.Bcc.Add(x)); return message; }
public void SetUp() { theMessageBody = new StringBuilder(); theMessageBody.AppendLine("MIME-Version: 1.0"); theMessageBody.AppendLine("From: [email protected]"); theMessageBody.AppendLine("To: [email protected], [email protected]"); theMessageBody.AppendLine("Cc: [email protected]"); theMessageBody.AppendLine("Subject: This is a test"); theMessageBody.AppendLine("Content-Type: text/plain; charset=us-ascii"); theMessageBody.AppendLine("Content-Transfer-Encoding: quoted-printable"); theMessageBody.AppendLine(); theMessageBody.AppendLine("This is the body"); theMessageBody.AppendLine().AppendLine(".").AppendLine(); theParser = new MessageParser(); theMessage = theParser.Parse(theMessageBody.ToString()); }