| Server IP : 199.79.62.161 / Your IP : 216.73.216.245 [ Web Server : Microsoft-IIS/10.0 System : Windows NT MDUS-PP-WB12 10.0 build 20348 (Windows Server 2022) AMD64 User : IWPD_5096(nirmaowd) ( 0) PHP Version : 8.3.30 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/INETPUB/VHOSTS/nirmalamatha.edu.in/ponnuguruvayurappan.org/App_Code/ |
Upload File : |
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Mail;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Some Common Functions for this Web Site
/// </summary>
public class CommonFunctions
{
public static string smtpServerString = "relay-hosting.secureserver.net";
public CommonFunctions()
{
//
// TODO: Add constructor logic here
//
}
public static string ValidSQL(string content)
{
return content.Replace("'", "''");
}
/// <summary>
/// Sends an Email to the specified email address. Returns true if succeded or false if failed.
/// </summary>
/// <param name="fromEmail"></param>
/// <param name="toEmail"></param>
/// <param name="bccEmail"></param>
/// <param name="subject"></param>
/// <param name="mailBody"></param>
/// <returns></returns>
public static bool SendEmail(string fromEmail, string toEmail, string bccEmail, string subject, string emailBody)
{
bool returnStatus = false;
MailMessage mail = new MailMessage();
SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
mail.BodyFormat = MailFormat.Html;
mail.Subject = subject;
mail.From = fromEmail;
if (toEmail != "")
mail.To = toEmail;
if (bccEmail != "")
mail.Bcc = bccEmail;
mail.Body = emailBody;
try
{
SmtpMail.Send(mail);
returnStatus = true;
}
catch (Exception)
{
returnStatus = false;
}
return returnStatus;
}
/// <summary>
/// Validate a Form control with specified values
/// </summary>
/// <param name="strField"></param>
/// <param name="strValue"></param>
/// <param name="intMinLength"></param>
/// <param name="intMaxLength"></param>
/// <returns></returns>
public static string ValidateFormField(string strField, string strValue, int intMinLength, int intMaxLength)
{
string errmsg = "";
if (intMinLength > 0)
{
if (strValue.Length < intMinLength)
{
errmsg = errmsg + " | '" + strField + "' should be at least " + intMinLength + " characters";
}
}
if (intMaxLength > 0)
{
if (strValue.Length > intMaxLength)
{
errmsg = errmsg + " | '" + strField + "' should be less than " + intMaxLength + " characters";
}
}
return errmsg;
}
}