hello mb,
In 1.9v website I created a 3rd request quote form in which is similar to the
first request quote form, updated for 1.90 The only difference is that instead of sending it to store owner - I am sending it to 3 different recipients.
I have created settings for cc bcc - saved the correct e-mail address from administration area (in database) still the second person who is based on bcc never gets any e-mail, why ? If I put number of email address in one (bcc or cc) then store owner gets the email which means something is not working fine in the code.
This is my what I have:
The first request quote form, updated for 1.90:
(Quote.ascx.cs)using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Text;
using System.Web.UI;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Audit;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Messages;
using NopSolutions.NopCommerce.Common.Utils.Html;
namespace NopSolutions.NopCommerce.Web.Modules
{
public partial class Quote : BaseNopUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRequestQuote_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
string emailTitle = "For Quote";
string fullName = txtFullName.Text.Trim();
string contactNumber = txtContactNumber.Text.Trim();
string email = txtEmail.Text.Trim();
string company = txtCompany.Text.Trim();
string companyAddress = txtCompanyAddress.Text.Trim();
string secondary = txtEnquiry.Text.Trim();
string extra = txtExtra.Text.Trim();
string subject = "Registration - New Member Information";
var body = new StringBuilder();
body.AppendFormat("<hr />{0} ({1})<hr />", emailTitle, DateTime.Now.ToShortDateString());
body.AppendFormat("<b>{0}:</b> {1}<br />", "Full Name: ", fullName);
body.AppendFormat("<b>{0}:</b> {1}<br />", "Company: ", company);
body.AppendFormat("<b>{0}:</b> {1}<br />", "Contact No. (Primary): ", contactNumber);
body.AppendFormat("<b>{0}:</b> {1}<br />", "Contact No. (Sec): ", secondary);
body.AppendFormat("<b>{0}:</b> {1}<br />", " E-mail Address: ", email);
body.AppendFormat("<b>{0}:</b> {1}<br />", "Products: ", companyAddress);
body.Append("<br />");
body.AppendFormat("<b>{0}:</b><br /> {1}<br />", "SecondProduct", extra.FormatContactUsFormText());
var from = new MailAddress(email, fullName);
var emailAccount = this.MessageService.DefaultEmailAccount;
string body2 = body.ToString();
//required for some SMTP servers
if (SettingManager.GetSettingValueBoolean("Email.UseSystemEmailForContactUsForm"))
{
from = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
body2 = string.Format("<b>From</b>: {0} - {1} <br /><br />{2} ", Server.HtmlEncode(fullName), Server.HtmlEncode(email), body2);
}
var to = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
// if set, allows message to be sent to recipient (email address) other than default email account
string toEmail = SettingManager.GetSettingValue("RecipientFirst.ToEmail", String.Empty).Trim();
if (string.IsNullOrEmpty(toEmail) == false)
{
try
{
to = new MailAddress(toEmail);
}
catch (Exception)
{ }
}
string ccEmails = SettingManager.GetSettingValue("RecipientThird.ccEmails", String.Empty);
string bccEmails = SettingManager.GetSettingValue("RecipientSecond.bccEmails", String.Empty);
List<string> bcc = new List<string>();
foreach (string str1 in bccEmails.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
bcc.Add(str1);
}
List<string> cc = new List<string>();
foreach (string str1 in ccEmails.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
cc.Add(str1);
}
this.MessageService.InsertQueuedEmail(5, from, to, ccEmails, bccEmails, subject, body2,
DateTime.UtcNow, 0, null, emailAccount.EmailAccountId);
pnlResult.Visible = true;
pnlRequestQuote.Visible = false;
}
catch (Exception exc)
{
this.LogService.InsertLog(LogTypeEnum.MailError, string.Format("Error sending \"Quote\" email."), exc);
}
}
}
}
}
---------------------------IN MY ALL SETTINGS------------
RecipientFirst.ToEmail : [email protected]
RecipientSecond.bccEmails: [email protected]; [email protected]
RecipientThird.ccEmails : [email protected]