We are using this Conlib File on our Able 7.7 version. Tried using it on the Gold version but it is not working for some reason any help please. Thanks in advance.
<%@ Control Language="C#" ClassName="ContactUs" %>
<script runat="server">
private string _sendTo;
public string SendTo
{
get { return _sendTo; }
set { _sendTo = value; }
}
protected void SendButton_Click(object sender, EventArgs e)
{
Store store = Token.Instance.Store;
StoreSettingCollection settings = store.Settings;
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
if (String.IsNullOrEmpty(SendTo))
{
mailMessage.To.Add(settings.DefaultEmailAddress);
}
mailMessage.From = new System.Net.Mail.MailAddress(Email.Text);
mailMessage.Subject ="Feedback";
mailMessage.Body += "Name: "+Name.Text+Environment.NewLine;
mailMessage.Body += "Email: " + Email.Text + Environment.NewLine;
mailMessage.Body += "Phone: "+Phone.Text+Environment.NewLine;
mailMessage.Body += "Product: "+Product.Text+Environment.NewLine;
mailMessage.Body += "Comment: "+Environment.NewLine+Comment.Text;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.IsBodyHtml = false;
mailMessage.Priority = System.Net.Mail.MailPriority.High;
SmtpSettings smtpSettings = SmtpSettings.DefaultSettings;
try
{
MessageLabel.Text = "Message Sent";
MessageLabel.CssClass = "goodCondition";
EmailClient.Send(mailMessage);
}
catch (Exception exp)
{
MessageLabel.Text = exp.Message;
MessageLabel.CssClass = "errorCondition";
}
}
</script>
<table cellpadding="0" cellspacing="0" class="inputForm">
<tr>
<th style="text-align:right;padding-right:3px;">
Name</th>
<td>
<asp:TextBox ID="Name" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Name"
ErrorMessage="Name is Required." ToolTip="Name is Required."
Display="Static" Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th style="text-align:right;padding-right:3px;">
Email</th>
<td>
<asp:TextBox ID="Email" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="Email Address is Required." ToolTip="Email Address is Required."
Display="Static" Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="EmailValidator" runat="server" Display="Static"
ControlToValidate="Email" ValidationExpression="\S+@\S+\.\S+" ErrorMessage="The email address is not properly formatted."
Text="*" ValidationGroup="ContactUs"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<th style="text-align:right;padding-right:3px;">
Phone</th>
<td>
<asp:TextBox ID="Phone" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorPhone" runat="server" ControlToValidate="Phone"
ErrorMessage="Name is Required." ToolTip="Phone is required."
Display="Static" Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th style="text-align:right;padding-right:3px;">
Product</th>
<td>
<asp:TextBox ID="Product" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorProduct" runat="server" ControlToValidate="Product"
ErrorMessage="Name is Required." ToolTip="Product."
Display="Static" Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th style="text-align:right;padding-right:3px;">
Comment</th>
<td>
<asp:TextBox ID="Comment" runat="server" TextMode="MultiLine" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Comment"
ErrorMessage="Comment is Required." ToolTip="Leave comments or ask questions."
Display="Static" Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="SendButton" runat="server" Text="Send" ValidationGroup="ContactUs" OnClick="SendButton_Click" /></td>
</tr>
<tr>
<td></td>
<td >
<asp:Label ID="MessageLabel" runat="server"></asp:Label>
<asp:ValidationSummary ID="ContactUsSummary" runat="server" ValidationGroup="ContactUs" />
</td>
</tr>
</table>[/code]
Contact us Conlib
Re: Contact us Conlib
Yes, quite a few things changed from 7.0.7 to GOLD. This should get you started. Change the
lines to
The big thing is the Token.Instance is replace by the AbleContext.Current.
Code: Select all
Store store = Token.Instance.Store;
StoreSettingCollection settings = store.Settings;
Code: Select all
Store _store = AbleContext.Current.Store;
StoreSettingsManager _settings = _store.Settings;
Re: Contact us Conlib
Yeah I have noticed that David. I made the change you mentioned but now I am getting this error in the error log filedavid-ebt wrote:Yes, quite a few things changed from 7.0.7 to GOLD. This should get you started. Change the
lines toCode: Select all
Store store = Token.Instance.Store; StoreSettingCollection settings = store.Settings;
The big thing is the Token.Instance is replace by the AbleContext.Current.Code: Select all
Store _store = AbleContext.Current.Store; StoreSettingsManager _settings = _store.Settings;
Error sending email with subject 'Feedback'.
Exception: A recipient must be specified. Stack Trace: at System.Net.Mail.SmtpClient.Send(MailMessage message) at CommerceBuilder.Messaging.EmailClient.Send(MailMessage mailMessage, SmtpSettings smtpSettings, Boolean throwOnError)
Thanks Richard
Re: Contact us Conlib
Richard,
This code worked for me:
Do you have the default email addresses set up in the Configure >> Email >> Settings page? That's where the "TO" email address comes from.
This code worked for me:
Code: Select all
<%@ Control Language="C#" ClassName="ContactUs" %>
<script runat="server">
private string _sendTo;
public string SendTo
{
get { return _sendTo; }
set { _sendTo = value; }
}
protected void SendButton_Click(object sender, EventArgs e)
{
Store _store = AbleContext.Current.Store;
StoreSettingsManager _settings = _store.Settings;
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
if (String.IsNullOrEmpty(SendTo))
{
mailMessage.To.Add(_settings.DefaultEmailAddress);
}
mailMessage.From = new System.Net.Mail.MailAddress(Email.Text);
mailMessage.Subject = "Feedback";
mailMessage.Body += "Name: " + Name.Text + Environment.NewLine;
mailMessage.Body += "Email: " + Email.Text + Environment.NewLine;
mailMessage.Body += "Phone: " + Phone.Text + Environment.NewLine;
mailMessage.Body += "Product: " + Product.Text + Environment.NewLine;
mailMessage.Body += "Comment: " + Environment.NewLine + Comment.Text;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.IsBodyHtml = false;
mailMessage.Priority = System.Net.Mail.MailPriority.High;
SmtpSettings smtpSettings = SmtpSettings.DefaultSettings;
try
{
MessageLabel.Text = "Message Sent";
MessageLabel.CssClass = "goodCondition";
EmailClient.Send(mailMessage);
}
catch (Exception exp)
{
MessageLabel.Text = exp.Message;
MessageLabel.CssClass = "errorCondition";
}
}
</script>
<table cellpadding="0" cellspacing="0" class="inputForm">
<tr>
<th style="text-align: right; padding-right: 3px;">
Name
</th>
<td>
<asp:TextBox ID="Name" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Name"
ErrorMessage="Name is Required." ToolTip="Name is Required." Display="Static"
Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th style="text-align: right; padding-right: 3px;">
Email
</th>
<td>
<asp:TextBox ID="Email" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="Email Address is Required." ToolTip="Email Address is Required."
Display="Static" Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="EmailValidator" runat="server" Display="Static"
ControlToValidate="Email" ValidationExpression="\S+@\S+\.\S+" ErrorMessage="The email address is not properly formatted."
Text="*" ValidationGroup="ContactUs"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<th style="text-align: right; padding-right: 3px;">
Phone
</th>
<td>
<asp:TextBox ID="Phone" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorPhone" runat="server" ControlToValidate="Phone"
ErrorMessage="Name is Required." ToolTip="Phone is required." Display="Static"
Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th style="text-align: right; padding-right: 3px;">
Product
</th>
<td>
<asp:TextBox ID="Product" runat="server" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorProduct" runat="server" ControlToValidate="Product"
ErrorMessage="Name is Required." ToolTip="Product." Display="Static" Text="*"
ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th style="text-align: right; padding-right: 3px;">
Comment
</th>
<td>
<asp:TextBox ID="Comment" runat="server" TextMode="MultiLine" ValidationGroup="ContactUs"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Comment"
ErrorMessage="Comment is Required." ToolTip="Leave comments or ask questions."
Display="Static" Text="*" ValidationGroup="ContactUs">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="SendButton" runat="server" Text="Send" ValidationGroup="ContactUs"
OnClick="SendButton_Click" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="MessageLabel" runat="server"></asp:Label>
<asp:ValidationSummary ID="ContactUsSummary" runat="server" ValidationGroup="ContactUs" />
</td>
</tr>
</table>
Re: Contact us Conlib
Thanks David That seemed to work.
Richard
Richard