%@ Page Language="C#" %>
<%@ Import Namespace="System.Net.Mail" %>
<%
string type= Request.RequestType;
String name = Request.Form["name"].ToString();
String forname =Request.Form["forname"].ToString();
String company = Request.Form["company"].ToString();
String occupation = Request.Form["occupation"].ToString();
String age = Request.Form["age"].ToString();
String email_address = Request.Form["email_address"].ToString();
String address = Request.Form["address"].ToString();
String post_code = Request.Form["post_code"].ToString();
String city = Request.Form["city"].ToString();
String country = Request.Form["country"].ToString();
String phone_number = Request.Form["phone_number"].ToString();
String mobile_phone_number = Request.Form["mobile_phone_number"].ToString();
String details_of_request = Request.Form["details_of_request"].ToString();
String legal_mentio = Request.Form["legal_mentio"].ToString();
string hostName = Request.Url.Host;
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
//doc.Load(Server.MapPath("~/MailConfig.xml"));
string mapPath=Server.MapPath(".");
mapPath += "\\MailConfig.xml";
doc.Load(mapPath);
System.Xml.XmlNode root = doc.DocumentElement;
String dominName = root.SelectSingleNode("dataMail/domainName").ChildNodes[0].Value;
String mailFrom = root.SelectSingleNode("dataMail/mailFrom").ChildNodes[0].Value;
String mailTo = root.SelectSingleNode("dataMail/mailTo").ChildNodes[0].Value;
String mailTitle = root.SelectSingleNode("dataMail/mailTitle").ChildNodes[0].Value;
String smtpHost = root.SelectSingleNode("dataMail/smtpHost").ChildNodes[0].Value;
String enableSsl = root.SelectSingleNode("dataMail/enableSsl").ChildNodes[0].Value;
String smtpPortString = root.SelectSingleNode("dataMail/smtpPort").ChildNodes[0].Value;
String userName = root.SelectSingleNode("dataMail/userName").ChildNodes[0].Value;
String pass = root.SelectSingleNode("dataMail/pass").ChildNodes[0].Value;
String correctMialMsg = root.SelectSingleNode("dataMsg/correct").ChildNodes[0].Value;
String filedMialMsg = root.SelectSingleNode("dataMsg/failed").ChildNodes[0].Value;
String wwwDominName="www."+dominName;
if (hostName == dominName || hostName == wwwDominName || hostName == "localhost" || hostName =="rsiltr.makolab.pl" || hostName =="rsirtl.makolab.pl")
{
StringBuilder textMessage = new StringBuilder();
textMessage.Append("name= " + name + "
");
textMessage.Append("forname= " + forname + "
");
textMessage.Append("company= " + company + "
");
textMessage.Append("occupation= " + occupation + "
");
textMessage.Append("age= " + age + "
");
textMessage.Append("email_address= " + email_address + "
");
textMessage.Append("address= " + address + "
");
textMessage.Append("post_code= " + post_code + "
");
textMessage.Append("country= " + country + "
");
textMessage.Append("phone_number= " + phone_number + "
");
textMessage.Append("mobile_phone_number= " + mobile_phone_number + "
");
textMessage.Append("details_of_request= " + details_of_request + "
");
textMessage.Append("legal_mentio= " + legal_mentio + "
");
MailAddress from = new MailAddress(mailFrom);
MailAddress to = new MailAddress(mailTo);
MailMessage message = new MailMessage(from, to);
message.Subject = mailTitle;
message.Body = textMessage.ToString();
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
SmtpClient client = new SmtpClient(smtpHost, System.Int32.Parse(smtpPortString));
client.Credentials = new System.Net.NetworkCredential(userName, pass);
client.EnableSsl = true;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.EnableSsl = System.Boolean.Parse(enableSsl);
try
{
client.Send(message);
Response.Write(correctMialMsg);
}
catch (Exception ex)
{
Response.Write(ex.Message+"
");
Response.Write(filedMialMsg);
}
}
else
{
Response.Write(filedMialMsg);
}
%>