Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Net;
- 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 System.Web.Mail;
- using System.Net.Mail;
- public partial class contactus : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void submit_Click(object sender, EventArgs e)
- {
- try
- {
- string strSubject = "New Contact details dated " + System.DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss");
- string strbody = generateBody();
- //string strResp = CommonFunction.SendMail(email0.t
- //string strResp = CommonFunction.SendMail(email0.Text.Trim(), strSubject, strbody);
- //MailMessage msg = new MailMessage();
- MailMessage msg = new MailMessage();
- // string email = "mukeshftec@gmail.com";
- string email = "mansiagrawal123@gmail.com";
- //string txtFrom = "contact@3gsolutions.co.in";
- string txtFrom = "mukeshftec@gmail.com";
- //msg.To = email.Trim();
- msg.To.Add(email);
- //msg.From = txtFrom.Trim();
- msg.From = new MailAddress(txtFrom);
- msg.Subject = strSubject.Trim();
- msg.Body = strbody.Trim();
- //msg.BodyFormat = MailFormat.Html;
- msg.Priority = MailPriority.High;
- SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com");
- // SMTPServer.Port = 587;
- SMTPServer.Port = 465;
- SMTPServer.Credentials = new System.Net.NetworkCredential("mukeshftec@gmail.com", "anshulkamina");
- SMTPServer.EnableSsl = true;
- //SmtpMail.SmtpServer.Insert(0,"127.0.0.1");
- //SmtpMail.SmtpServer = "smtp.YourProvider.com";
- //SmtpMail.SmtpServer = "smtp.net4india.com";
- //SmtpMail.SmtpServer = "smtp.net4india.com";
- //SmtpMail.SmtpServer = "localhost";
- SMTPServer.UseDefaultCredentials = false;
- SMTPServer.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
- //SMTPServer.DeliveryMethod=msg
- SMTPServer.Send(msg);
- //if (strResp != "")
- //{
- // Page.ClientScript.RegisterStartupScript(this.GetType(), "op", "alert('" + strResp + "');", true);
- //}
- //else
- //{
- //Page.ClientScript.RegisterStartupScript(this.GetType(), "op", "alert('Message Sent Successfully.');", true);
- Response.Redirect("Thanks.html");
- //}
- }
- catch(Exception ex)
- {
- // Response.Write();
- }
- }
- public string generateBody()
- {
- string strHtml = "<style>.maintable {font-family: Arial, Verdana, Helvetica, sans-serif; color:Silver; font-size:11px;}</style>";
- strHtml += "<table class='maintable' border='0' width='100%' cellspacing='0' cellpadding='0'>";
- strHtml += "<tr>";
- strHtml += "<td colspan='2' align='center' style='color:white;background-color:navy;font-family:Arial; font-size:11px; font-weight:bold;'>New Contact Details</td>";
- strHtml += "</tr>";
- strHtml += "<tr>";
- strHtml += "<td align='left' style='width:20%'>Name:</td>";
- strHtml += "<td align='left' style='width:80%'>" + title.Text.Trim() + " " + firstName0.Text.Trim() + " " + middleName0.Text.Trim() + " " + lastName0.Text.Trim() + " " + "</td>";
- strHtml += "</tr>";
- if (jobTitle0.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Job Title:</td>";
- strHtml += "<td align='left'>" + jobTitle0.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (companyName0.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Company Name:</td>";
- strHtml += "<td align='left'>" + companyName0.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (website0.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Website:</td>";
- strHtml += "<td align='left'>" + website0.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (address3.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Address 1:</td>";
- strHtml += "<td align='left'>" + address3.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (address4.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Address 2:</td>";
- strHtml += "<td align='left'>" + address4.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (city0.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>City:</td>";
- strHtml += "<td align='left'>" + city0.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- //country
- if (ID_country0.SelectedIndex != 0)
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Country:</td>";
- strHtml += "<td align='left'>" + ID_country0.SelectedItem.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (email0.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Email-ID:</td>";
- strHtml += "<td align='left'>" + email0.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (phone0.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Phone:</td>";
- strHtml += "<td align='left'>" + phone0.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- if (notes0.Text != "")
- {
- strHtml += "<tr>";
- strHtml += "<td align='left'>Notes:</td>";
- strHtml += "<td align='left'>" + notes0.Text.Trim() + "</td>";
- strHtml += "</tr>";
- }
- strHtml += "</table>";
- return strHtml;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement