Critical Developers

Programmers Knowledge Base

Send Mail/Alerts before Expiry Date to your members with SQL Query (DATEADD(), DATEDIFF())

------------Send Mail/Alerts before Expiry Date to your members with SQL Query as per your condition :----------DATEADD(), DATEDIFF()

3 months before:-
select * from members where expirydate=DATE_ADD(NOW(), INTERVAL 3 MONTH);

1 month before:-
select * from members where expirydate=DATE_ADD(NOW(), INTERVAL 1 MONTH);

2 Day before:-
select * from members where datediff(expirydate,curdate())=2;

On Last Day:-
select * from members where datediff(hostexpirydate,curdate())=0;

FTP File Upload from aspx page

using System;
using System.Data;
using System.Configuration;
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.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Upload("ftp://ftp.domain.com", "testuser", "testpwd", @"C:\abc.txt");
                    }
    }

    public void Upload(string ftpServer, string userName, string password, string filename)
    {
        using (System.Net.WebClient client = new System.Net.WebClient())
        {
            try
            {
                   client.Credentials = new System.Net.NetworkCredential(userName, password);
                   client.UploadFile(ftpServer + "/" + new FileInfo(filename).Name, "STOR", filename);              
            }
            catch (Exception ex)
            {

            }
        }
    }
}