:master:
Se non ho capito male ti serve qualcosa come quanto segue :
(
Il codice lo trovi anche allegato spero...
Rinominare da ".gif" in ".aspx"
Ed ovviamente ignorare ed eliminare i primi caratteri
cioe' "GIF89a$"
)
codice:
<%@Page Language="C#" Debug="true"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web.Mail" %>
<script language="C#" runat="server">
void Page_Load (Object sender, EventArgs e)
{
if (IsPostBack)
{
Messaggio.InnerHtml = "<font color=\"red\" style=\"font: 8pt verdana;\">Note : All fields are required!</font></br>";
}
}
void doSend (Object sender, EventArgs e)
{
if ((frmName.Text != "") && (frmEmail.Text != "") && (frmComment.Text != ""))
{
try
{
string body = "";
MailMessage mail = new MailMessage();
body = frmComment.Text.Replace("'", "''").Replace("\"", "\"");
body += "\n\n______________________________________________________________________________________";
body += "\nMittente : " + frmName.Text;
body += "\n Email : " + frmEmail.Text;
body += "\n IP : " + Request.ServerVariables["REMOTE_ADDR"].ToString();
body += "\n Time : " + DateTime.Now.ToString();
body += "\n\n______________________________________________________________________________________";
mail.To = "tuaemail@dominio.ext"; // qui configuri l'email di chi dovra' ricevere il messaggio con il commento
mail.From = frmEmail.Text;
mail.Subject = "Information request by " + frmName.Text + ".";
mail.Body = body;
// mail.BodyFormat = MailFormat.Html;
mail.Priority = MailPriority.High;
SmtpMail.SmtpServer = "localhost"; // o tuo smtp che non richiede autenticazione es. smtp.tiscali.it
SmtpMail.Send(mail);
Messaggio.InnerHtml = "</br>Tutto Ok!</br>";
}
catch (Exception ex)
{
Messaggio.InnerHtml = "<font color=\"white\">Exception : " + ex.ToString().Replace("\r\n", "</br>") + "</font>";
}
}
else
{
Messaggio.InnerHtml = "<font color=\"red\" style=\"font: 8pt verdana;\">Note : All fields are required!</font></br>";
Response.Redirect(Request.Url.ToString());
}
}
</script>
<html>
<head>
<title>Contact Form.</title>
</head>
<style>
body{
position: Static !important;
padding: 0px 0px !important;
width: 800px !important;
height: 600px !important;
margin: Auto !important;
background: #20A0A0 !important;
color: Black !important;
}
a{
color: Blue;
text-decoration: None;
}
a:active{
color: Blue;
text-decoration: None;
}
a:visited{
color: Blue;
text-decoration: None;
}
a:hover{
color: LightBlue;
text-decoration: None;
}
</style>
<body>
<div align="center">
<form method="post" runat="server">
<asp:TextBox id="frmName" Columns="86" Value="Insert your Name Here!" runat="server"/>
<asp:RequiredFieldValidator id="vldfrmName" ControlToValidate="frmName" ErrorMessage="Name is Required" display="dynamic" runat="server"> Required!</asp:RequiredFieldValidator></br>
<asp:TextBox id="frmEmail" Columns="86" Value="Insert your Em@il here!" runat="server"/>
<asp:RegularExpressionValidator id="vldfrmEmail" ControlToValidate="frmEmail" ValidationExpression="(\w+|\W+)([-+.](\w+|\W+))*@(\w+|\W+)([-.](\w+|\W+))*\.(\w+|\W+)([-.](\w+|\W+))*" ErrorMessage="A valid Email address is Required!" display="dynamic" runat="server">A valid Email address is Required!</asp:RegularExpressionValidator></br>
<asp:TextBox id="frmComment" Rows="24" Columns="65" TextMode="MultiLine" runat="server"/></br>
<asp:RequiredFieldValidator id="vldfrmComment" ControlToValidate="frmComment" ErrorMessage="A comment is Required!" display="dynamic" runat="server" > Required!</asp:RequiredFieldValidator>
<p align="center">
<asp:Button id="Button" text="Send" OnClick="doSend" runat="server"/>
</p>
<span id="Messaggio" style="font: 8pt verdana;" runat="server"/>
</form>
</div>
</body>
</html>