This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Fri Aug 15, 2008 7:39 am
This is a simple sample that how to write a Feedback or contact control for AbleCommerce using the AbleCommerce configured SMTP settings. Please download the attachment for the source code of the control. The control exposes a single property
SendTo that is used to specify the Email address where you want to receive the Emails sent by the control. You can use it like any other control
Code: Select all
[[ConLib:ContactUs SendTo="info@yourstore.com"]]
Note: If you don't configured this SendTo property the Email will be sent to your default Email address which you configured for the store in the SMTP settings.
ContactUs control version supporting AbleCommerce 7.0.8 Gold is avilable here viewtopic.php?f=47&t=17102
[SCREEN SHOT]
-
Mike718NY
- Commodore (COMO)
- Posts: 485
- Joined: Wed Jun 18, 2008 5:24 pm
Post
by Mike718NY » Fri Aug 15, 2008 9:42 am
Thanks for that. That's very useful.
But I would add a "Subject" line also.
Or maybe get rid of "Name". People will usually put that in the message.
-
Robbie@FireFold
- Commodore (COMO)
- Posts: 433
- Joined: Wed May 28, 2008 9:42 am
- Location: Concord, NC
-
Contact:
Post
by Robbie@FireFold » Fri Aug 15, 2008 10:32 am
Beautiful.
I have this same control in my current software. You would be shocked how many customers use it - I assume because its 'easy.'
Thanks!
-
harris43
- Lieutenant (LT)
- Posts: 64
- Joined: Fri Oct 13, 2006 12:17 pm
Post
by harris43 » Mon Aug 18, 2008 1:04 pm
Where can you alter where the contents of this message is sent to?
I don't see where it is sending the form.
-
harris43
- Lieutenant (LT)
- Posts: 64
- Joined: Fri Oct 13, 2006 12:17 pm
Post
by harris43 » Mon Aug 18, 2008 1:06 pm
oops. Now I see it above.
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Fri Oct 24, 2008 9:00 am
This is an update to existing contact us control. In order to avoid spams we can extend the contact us control to support the captcha code. I have used the captcha available with AbleCommerce. In order to install the control just extract the control files and place them in the ConLib. The control Supports an
EnableCaptcha property which you can set to
True/False to enable or disable captcha. By default the captcha is enabled. You can change the mail subject by using
Subject property. You can set
SendTo property to specify the Email address where you want to receive the messages. If you don't specify this property the Email will be sent to store's default Email address. For example you can place the control in some store page as bellow
Code: Select all
[[ConLib:ContactUs SendTo="info@mystore.com" ]]
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Tue Nov 04, 2008 6:12 am
You can easily incorporate the attachment ability in the contactus control. Here is the modified version of the ContactUs control with attachment support
-
Jaz
- Captain (CAPT)
- Posts: 245
- Joined: Wed Nov 05, 2008 4:04 am
- Location: Torrance, CA
-
Contact:
Post
by Jaz » Sat Nov 22, 2008 9:24 pm
I must be doing something wrong. I have tried to apply this Contact Us control and I can't get it to work. I have tried it in the conlib folder and in the custom folder.
I am putting it in the "Sidebar 2" section in the "Shopping Bar 1"
Code: Select all
[[ConLib:ContactUs SendTo="david@trickconcepts.com" ]]
[[ConLib:MiniBasket]]
[[ConLib:custom/RecentlyViewed]]
The control works fine and says that the message is sent, but I never receive it. I have tried chaning the SendTo Email address and removing it all together, but it makes no difference.
Any Suggestions?
Thanks,
Jaz
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
-
Jaz
- Captain (CAPT)
- Posts: 245
- Joined: Wed Nov 05, 2008 4:04 am
- Location: Torrance, CA
-
Contact:
Post
by Jaz » Sat Nov 22, 2008 9:42 pm
I just found out something else. My shipping calculator had not been working right. I had the minibasket in the Sidebar 2 with the ContactUs Control. When I set the ContactUs control to Visible="false" the shipping calculator started to work again?
Do you think this is related, or just a coincidence?
If this is the problem, how do I adjust the ContactUs controls to work in the Sidebar2? If I can't adjust it, where do I need to put the ContactUs control?
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Mon Nov 24, 2008 8:15 am
Which version of the control you are using, I mean the simple one, with captcha or the the one with attachment facility.
-
Jaz
- Captain (CAPT)
- Posts: 245
- Joined: Wed Nov 05, 2008 4:04 am
- Location: Torrance, CA
-
Contact:
Post
by Jaz » Mon Nov 24, 2008 2:33 pm
I have tried the second 2 - I'll try the simple one.
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
-
Jaz
- Captain (CAPT)
- Posts: 245
- Joined: Wed Nov 05, 2008 4:04 am
- Location: Torrance, CA
-
Contact:
Post
by Jaz » Mon Nov 24, 2008 2:59 pm
I just tried the simple one in both the right side bar and the main content area. I can't get anthing to send. It tells me the message is sent. I have tried it in bot custom and in the conlib folder. Here is the syntax I am using.
Code: Select all
[[ConLib:custom/ContactUs SendTo="david@trickconcepts.com" Visible="true"]]
[[ConLib:custom/MiniBasket]]
[[ConLib:custom/RecentlyViewed]]
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
-
Jaz
- Captain (CAPT)
- Posts: 245
- Joined: Wed Nov 05, 2008 4:04 am
- Location: Torrance, CA
-
Contact:
Post
by Jaz » Mon Nov 24, 2008 7:36 pm
I got it working. It was a SMTP Error.
Thanks,
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
-
wave_werks
- Lieutenant Commander (LCDR)
- Posts: 91
- Joined: Mon Sep 22, 2008 8:37 pm
- Location: Northeast Ohio
-
Contact:
Post
by wave_werks » Mon Dec 22, 2008 11:23 am
mazhar wrote:You can set
SendTo property to specify the Email address where you want to receive the messages. If you don't specify this property the Email will be sent to store's default Email address.
Code: Select all
[[ConLib:ContactUs SendTo="info@mystore.com" ]]
I'm using this control as it was provided here as well as a heavily modified version. Each is on its own page. One of the forms is ok to send to the default email address but I'd like the other to be sent to an address specified in the control. I've added the alternate email address as you have shown above but still only receive the email at the default email address. Is there somewhere else that I need to make a change?
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Mon Dec 22, 2008 12:04 pm
I'm using this control as it was provided here as well as a heavily modified version. Each is on its own page. One of the forms is ok to send to the default email address but I'd like the other to be sent to an address specified in the control. I've added the alternate email address as you have shown above but still only receive the email at the default email address. Is there somewhere else that I need to make a change?
I have checked the above two versions of control by providing different Email addresses in SendTo property and they worked fine. Have you customized something?
Check the below code it is responsible for Email address selection. If you haven't provided something for SendTo property then it will pick the store default address other wise it will send Email to the address specified in the SendTo property.
Code: Select all
if (String.IsNullOrEmpty(SendTo))
mailMessage.To.Add(settings.DefaultEmailAddress);
else
mailMessage.To.Add(SendTo);
-
wave_werks
- Lieutenant Commander (LCDR)
- Posts: 91
- Joined: Mon Sep 22, 2008 8:37 pm
- Location: Northeast Ohio
-
Contact:
Post
by wave_werks » Mon Dec 22, 2008 12:35 pm
mazhar wrote:Check the below code it is responsible for Email address selection. If you haven't provided something for SendTo property then it will pick the store default address other wise it will send Email to the address specified in the SendTo property.
Code: Select all
if (String.IsNullOrEmpty(SendTo))
mailMessage.To.Add(settings.DefaultEmailAddress);
else
mailMessage.To.Add(SendTo);
I'm a complete and total novice at this stuff. How do I add my preferred SendTo address in that part of the code? I'm not exactly sure of how to modify it without messing it all up and making it unusable.
I've already added my preferred address the SendTo in this section:
Code: Select all
[[ConLib:ContactUs SendTo="info@mystore.com" ]]
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Mon Dec 22, 2008 12:38 pm
Then the control must send the Email address to that address you specified in the SendTo property.
-
wave_werks
- Lieutenant Commander (LCDR)
- Posts: 91
- Joined: Mon Sep 22, 2008 8:37 pm
- Location: Northeast Ohio
-
Contact:
Post
by wave_werks » Mon Dec 22, 2008 12:51 pm
mazhar wrote:Then the control must send the Email address to that address you specified in the SendTo property.
That's what I thought but it definitely does not. I just changed the unmodified version to send to an alternate address and it still sends to the default address and not to the alternate address.
There is nowhere in the .ascx or the ascx.cs file that needs to have the alternate address added?
-
Tomgard
- Lieutenant Commander (LCDR)
- Posts: 108
- Joined: Sun Jul 20, 2008 1:00 pm
Post
by Tomgard » Fri Dec 26, 2008 4:11 pm
What I am finding is that the users of this control are submitting their request multiple times becuase they are 'unsure' if the message has been sent.
Is it possible to add in a successful redirect page upon submission of a contact request?
I created an auto reply based on the 'sendto' address but this did not help becuase of the delay in the email client.
-
jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
-
Contact:
Post
by jmestep » Fri Dec 26, 2008 5:39 pm
On a contact form I made, I moved the message up above the send button so it would be more obvious that it was sent. I also cleared the fields in the form after the message was sent. I think you could do that in this one in this section of code:
try
{
MessageLabel.Text = "Message Sent";
MessageLabel.CssClass = "goodCondition";
EmailClient.Send(mailMessage);
[Add this]
Email.Text="";
Name.Text="";
Comment.Text="";
}
Maybe with combination of both, the customer would realize that the message had been sent without your having to make a confirmation page.
[edited to capital T in Text]
Last edited by
jmestep on Fri Oct 09, 2009 11:31 am, edited 1 time in total.
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Tue Dec 30, 2008 10:28 am
If you have some page which you want to show to customer on successful submission of message, for this you can just put a Response.Redirect statement just after the point where EmailClient.Send is called. For example if you have some MessageSent.aspx page then you can adjust your code as below
Code: Select all
try
{
MessageLabel.Text = "Message Sent";
MessageLabel.CssClass = "goodCondition";
EmailClient.Send(mailMessage);
Response.Redirect("~/MessageSent.aspx");
[Add this]
Email.text="";
Name.text="";
Comment.text="";
}
-
Tomgard
- Lieutenant Commander (LCDR)
- Posts: 108
- Joined: Sun Jul 20, 2008 1:00 pm
Post
by Tomgard » Sun Jan 04, 2009 1:44 pm
Mahzar -
I have created a MessageSent.aspx page but I am not 100% on the modification that needs to be done to ContactUs.ascx.cs in order to create the redirect to this page upon a message submit. Can you clarify this? I am using your ExtendedContactUs code that includes the attachement as seen below -
Code: Select all
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CommerceBuilder.Utility;
using System.Text;
using System.Net;
using System.Net.Mail;
using CommerceBuilder.Common;
using CommerceBuilder.Stores;
using System.Net.Mail;
using CommerceBuilder.Messaging;
using System.IO;
public partial class ConLib_ContactUs : System.Web.UI.UserControl
{
private bool _enableCaptcha = true;
[Personalizable(), WebBrowsable()]
public bool EnableCaptcha
{
get { return _enableCaptcha; }
set { _enableCaptcha = value; }
}
private string _subject = "New Contact Message";
[Personalizable(), WebBrowsable()]
public string Subject
{
get { return _subject; }
set { _subject = value; }
}
private string _successMessage = "Thank you for contacting us. Your message has been submitted. If needed, we may contact you at the email address you have provided.";
private string _failureMessage = "We are experiencing some problems at this time and can not process your request.";
private string _sendTo;
[Personalizable(), WebBrowsable()]
public string SendTo
{
get { return _sendTo; }
set { _sendTo = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
CaptchaPanel.Visible = EnableCaptcha;
}
private void RefreshCaptcha()
{
CaptchaImage.ChallengeText = StringHelper.RandomNumber(6);
}
protected void ChangeImageLink_Click(object sender, EventArgs e)
{
RefreshCaptcha();
}
protected void Submit_Click(object sender, EventArgs e)
{
if(EnableCaptcha)
{
if (CaptchaImage.Authenticate(CaptchaInput.Text))
{
SubmitComment();
CaptchaInput.Text = "";
RefreshCaptcha();
}
else
{
//CAPTCHA IS VISIBLE AND DID NOT AUTHENTICATE
CustomValidator invalidInput = new CustomValidator();
invalidInput.Text = "*";
invalidInput.ErrorMessage = "You did not input the verification number correctly.";
invalidInput.IsValid = false;
phCaptchaValidators.Controls.Add(invalidInput);
CaptchaInput.Text = "";
RefreshCaptcha();
}
}
else
if(!EnableCaptcha)
{
SubmitComment();
}
}
protected void SubmitComment()
{
Store store = Token.Instance.Store;
StoreSettingCollection settings = store.Settings;
MailMessage mailMessage = new MailMessage();
if (String.IsNullOrEmpty(SendTo))
mailMessage.To.Add(settings.DefaultEmailAddress);
else
mailMessage.To.Add(SendTo);
mailMessage.From = new System.Net.Mail.MailAddress(Email.Text);
mailMessage.Subject = Subject;
mailMessage.Body += "Name: " + FullName.Text + Environment.NewLine;
mailMessage.Body += "Email: " + Email.Text + Environment.NewLine;
mailMessage.Body += "Comment: " + Environment.NewLine + Comments.Text;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.IsBodyHtml = false;
if(AttachedFile.HasFile)
{
HttpPostedFile httpPostedFile = AttachedFile.PostedFile;
int attachedFileLength = httpPostedFile.ContentLength;
if (attachedFileLength > 0)
{
string attachedFileName = Path.GetFileName(httpPostedFile.FileName);
httpPostedFile.SaveAs(Server.MapPath("~/Assets/"+attachedFileName));
Attachment attachment = new Attachment(Server.MapPath("~/Assets/" + attachedFileName));
mailMessage.Attachments.Add(attachment);
}
}
mailMessage.Priority = System.Net.Mail.MailPriority.High;
SmtpSettings smtpSettings = SmtpSettings.DefaultSettings;
try
{
EmailClient.Send(mailMessage);
MessageLabel.Text = _successMessage;
MessageLabel.ForeColor = System.Drawing.Color.Green;
}
catch (Exception exp)
{
Logger.Error("ContactUs Control Exception: Exp" + Environment.NewLine + exp.Message);
MessageLabel.Text = _failureMessage;
MessageLabel.ForeColor = System.Drawing.Color.Red;
}
}
private string GetMessage()
{
StringBuilder body = new StringBuilder();
body.Append("Full Name:- " + FullName.Text + Environment.NewLine);
body.Append("Email:- " + Email.Text + Environment.NewLine);
body.Append("Comments:- " + Environment.NewLine);
body.Append(Comments.Text + Environment.NewLine);
return body.ToString();
}
}
-
mazhar
- Master Yoda
- Posts: 5084
- Joined: Wed Jul 09, 2008 8:21 am
-
Contact:
Post
by mazhar » Mon Jan 05, 2009 6:05 am
Locate following code
Code: Select all
try
{
EmailClient.Send(mailMessage);
MessageLabel.Text = _successMessage;
MessageLabel.ForeColor = System.Drawing.Color.Green;
}
and make it look like
Code: Select all
try
{
EmailClient.Send(mailMessage);
MessageLabel.Text = _successMessage;
MessageLabel.ForeColor = System.Drawing.Color.Green;
Response.Redirect("~/MessageSent.aspx");
}
-
Tomgard
- Lieutenant Commander (LCDR)
- Posts: 108
- Joined: Sun Jul 20, 2008 1:00 pm
Post
by Tomgard » Mon Jan 05, 2009 9:31 am
Works perfect - thanks!
-
Tomgard
- Lieutenant Commander (LCDR)
- Posts: 108
- Joined: Sun Jul 20, 2008 1:00 pm
Post
by Tomgard » Tue Jan 13, 2009 4:41 pm
Since I have been using this control I have been getting some errors logged in my view error log. The message says 'ContactUs Control Exception: EXP Thread was being aborted.' and the Debug Data section is blank. Any ideas what may cause this and why I am getting it?