Hi,
I've created a new contact us form but I have an issue when I get the email notificacion.
I only receive the default topic note.
I created two new topics called Topic1.ascx / Topic2.ascx, I can fill in but I don't get the email after I sent it.
this is what I have, will be great if someone can help me. What should Iput in order to get the info by email?
(I saw the "Memberinfo" model, but I cant running either)
Thanks in advance :-)
/modules/
ContactUs.ascx
<%@ Control Language="C#" AutoEventWireup="true" Inherits="NopSolutions.NopCommerce.Web.Modules.ContactUsControl"
CodeBehind="ContactUs.ascx.cs" %>
<%@ Register TagPrefix="nopCommerce" TagName="SimpleTextBox" Src="~/Modules/SimpleTextBox.ascx" %>
<%@ Register TagPrefix="nopCommerce" TagName="EmailTextBox" Src="~/Modules/EmailTextBox.ascx" %>
<%@ Register TagPrefix="nopCommerce" TagName="Topic" Src="~/Modules/Topic.ascx" %>
<%@ Register TagPrefix="nopCommerce" TagName="Topic1" Src="~/Modules/Topic1.ascx" %>
<%@ Register TagPrefix="nopCommerce" TagName="Topic2" Src="~/Modules/Topic2.ascx" %>
<div class="contact-form">
<div>
<nopCommerce:Topic ID="topicContactUs" runat="server" TopicName="ContactUs" OverrideSEO="false">
</nopCommerce:Topic>
</div>
<div class="clear">
</div>
<asp:Panel runat="server" ID="pnlResult" Visible="false" CssClass="result">
<strong>
<%=GetLocaleResourceString("ContactUs.YourEnquiryHasBeenSent")%></strong>
</asp:Panel>
<div class="clear">
</div>
<div class="send-email" runat="server" id="pnlContactUs">
<table class="table-container">
<tr class="row">
<td class="item-name">
<%=GetLocaleResourceString("ContactUs.FullName")%>:
</td>
<td class="item-value">
<nopCommerce:SimpleTextBox runat="server" ID="txtFullName" ValidationGroup="ContactUs"
Width="250px"></nopCommerce:SimpleTextBox>
</td>
</tr>
<tr class="row">
<td class="item-name">
<%=GetLocaleResourceString("ContactUs.E-MailAddress")%>:
</td>
<td class="item-value">
<nopCommerce:EmailTextBox runat="server" ID="txtEmail" ValidationGroup="ContactUs"
Width="250px"></nopCommerce:EmailTextBox>
</td>
</tr>
<tr class="row">
<td class="item-name">
<%=GetLocaleResourceString("ContactUs.Enquiry")%>:
</td>
<td class="item-value">
<asp:TextBox runat="server" ID="txtEnquiry" TextMode="MultiLine" SkinID="ContactUsEnquiryText"></asp:TextBox>
</td>
</tr>
<tr class="row">
<td class="item-name">
<%=GetLocaleResourceString("ContactUs.Enquiry1")%>:
</td>
<td class="item-value">
<asp:TextBox runat="server" ID="txtEnquiry1" TextMode="MultiLine" SkinID="ContactUsEnquiryText1"></asp:TextBox>
</td>
</tr>
<tr class="row">
<td class="item-name">
<%=GetLocaleResourceString("ContactUs.Enquiry2")%>:
</td>
<td class="item-value">
<asp:TextBox runat="server" ID="txtEnquiry2" TextMode="MultiLine" SkinID="ContactUsEnquiryText2"></asp:TextBox>
</td>
</tr>
<tr class="row">
<td class="item-name">
</td>
<td class="button">
<asp:Button runat="server" ID="btnContactUs" Text="<% $NopResources:ContactUs.ContactUsButton %>"
ValidationGroup="ContactUs" OnClick="btnContactUs_Click" CssClass="contactusbutton">
</asp:Button>
</td>
</tr>
</table>
</div>
</div>
-------
ContactUs.ascx.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Net.Mail;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Audit;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Messages;
using NopSolutions.NopCommerce.BusinessLogic.Utils.Html;
using NopSolutions.NopCommerce.Common.Utils;
using NopSolutions.NopCommerce.BusinessLogic.Infrastructure;
namespace NopSolutions.NopCommerce.Web.Modules
{
public partial class ContactUsControl: BaseNopFrontendUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindData();
}
protected void BindData()
{
if (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)
{
txtFullName.Text = NopContext.Current.User.FullName;
txtEmail.Text = NopContext.Current.User.Email;
}
}
protected void btnContactUs_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
if (String.IsNullOrEmpty(txtEnquiry.Text))
return;
string email = txtEmail.Text.Trim();
string fullName = txtFullName.Text.Trim();
string subject = string.Format("{0}. {1}", this.SettingManager.StoreName, "Contact us");
string body = txtEnquiry.Text.FormatContactUsFormText();
var from = new MailAddress(email, fullName);
var emailAccount = this.MessageService.DefaultEmailAccount;
//required for some SMTP servers
if (this.SettingManager.GetSettingValueBoolean("Email.UseSystemEmailForContactUsForm"))
{
from = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
body = string.Format("<b>From</b>: {0} - {1}<br /><br />{2}", Server.HtmlEncode(fullName), Server.HtmlEncode(email), body);
}
var to = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
this.MessageService.InsertQueuedEmail(5, from, to, string.Empty, string.Empty, subject, body,
DateTime.UtcNow, 0, null, emailAccount.EmailAccountId);
pnlResult.Visible = true;
pnlContactUs.Visible = false;
}
catch (Exception exc)
{
this.LogService.InsertLog(LogTypeEnum.MailError, string.Format("Error sending \"Contact us\" email."), exc);
}
}
}
}
}