Click here to Skip to main content
15,077,494 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey All,

Following contact form works in vs 2010, typically create application. In addition to application source code:
ASP.NET
Name: 
<asp:TextBox ID="txtName" runat="server" />
Email: 
<asp:TextBox ID="txtEmail" runat="server" />

Message: 
<asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" />

<asp:Button ID="btnSubmit" runat="server" Text="Send Email" 
onclick="btnSubmit_Click" />

and Code Behind:

DDL:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
 

protected void btnSubmit_Click(object sender, EventArgs e)
{
MailMessage message = new MailMessage();
message.To.Add("youremail@yahoo.com");
message.Subject = txtName.Text + " sent you a message via contact form";
message.From = new MailAddress(txtEmail.Text);
message.Body = txtContent.Text;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.Credentials = new NetworkCredential("youremail@yahoo.com", "yourpassword");
client.EnableSsl = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(message);
client.EnableSsl = true;
}

The question is, Why does not work in Umbraco CMS?

Thank you,
Jovan
Posted
Updated 21-Sep-12 11:16am
v2
Comments
[no name] 21-Sep-12 17:14pm
   
The port for SSL is 465
AspDotNetDev 21-Sep-12 19:30pm
   
FYI, you set "EnableSsl" twice in your example code.

I work with Umbraco every day, and it hasn't caused me any issues when sending email. Perhaps your server is just not configured to send email? Maybe a firewall is blocking email?

Use a try/catch block to catch any exceptions that may occur, and output them to the page. Also make sure your click handler is actually being run. When I can't debug Umbraco in Visual Studio, I typically use simple techniques like that to get debugging info.
   
I am not sure, but found one link which may be helpful for you.
Simple Contact Form Template For Umbraco[^].

Sorry if I am wrong...

Thanks...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900