Hi Joe,
Sorry it took so long to get this to you - I've been very busy this week.
If you could take a look through this, that would be great.
------------
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Load += new EventHandler(Page_Load);
btnSend.Click += new EventHandler(btnSend_Click);
Page.EnableViewState = true;
}
protected void Page_Load(object sender, EventArgs e)
{
Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);
if (WebUtils.ParseBoolFromHashtable(moduleSettings, "UseCaptcha", false) == true)
{
//Load captcha
captcha.ProviderName = siteSettings.CaptchaProvider;
captcha.Captcha.ControlID = "captcha" + ModuleId.ToInvariantString();
captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;
captcha.Visible = true;
}
else
{
captcha.Visible = false;
panelForm.Controls.Remove(captcha);
}
//If page is not post back, put URL into label to display and hidden form field
if (!Page.IsPostBack)
{
string currentPage = SiteUtils.GetCurrentPageUrl();
lblPage.Text = currentPage;
hidPageUrl.Value = currentPage;
}
}
protected void btnSend_Click(object sender, EventArgs e)
{
Submit();
//validate the page
Page.Validate();
if (!Page.IsValid) { return; }
WebUtils.SetupRedirect(this, Request.RawUrl);
}
private void Submit()
{
string html = string.Empty;
string cutUrl = string.Empty;
string fromEmail = string.Empty;
string yourName = string.Empty;
string yourEmail = string.Empty;
string friendEmail = string.Empty;
string page = string.Empty;
string subject = string.Empty;
string message = string.Empty;
string mailServer = string.Empty;
subject = "Referring you to this web page";
fromEmail = Settings["SharePageFromEmail"].ToString();
yourName = Server.HtmlEncode(txtYourName.Text);
yourEmail = Server.HtmlEncode(txtYourEmail.Text);
friendEmail = Server.HtmlEncode(txtFriendEmail.Text);
message = Server.HtmlEncode(txtMessage.Text);
page = Server.HtmlEncode(hidPageUrl.Value);
html = "";
html += "<P><FONT FACE=\"Arial\" COLOR=\"Black\" SIZE=\"4\"><B>" + yourName + " referred this web page to you:</B></FONT></P>";
html += "<P><FONT FACE=\"Arial\" COLOR=\"Black\" SIZE=\"2\"><A HREF=\"" + page + "\">" + page + "</A></FONT></P>";
if (message.Length > 0)
html += "<P><FONT FACE=\"Arial\" COLOR=\"Black\" SIZE=\"2\">" + message + "</FONT></P>";
try
{
Email.SendEmail(SiteUtils.GetSmtpSettings(), fromEmail, yourEmail, friendEmail, "", "", subject, html, true, Email.PriorityNormal);
lblMessage.Text = "Your message has been sent. Thank you!";
lblMessage.Visible = true;
panelForm.Visible = false;
ClearForm();
}
catch (Exception ex)
{
log.Error(ex);
lblMessage.Text = ex.InnerException.Message;
lblMessage.Visible = true;
}
}
-------
Thanks,
Matt