The ASP. NET upload reminder function is released on a monthly basis.

Source: Internet
Author: User
Tags mailmessage smtpclient

All the previous tokens are used as the proxies:

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "MailPJQGD. aspx. cs" Inherits = "MailPJQGD" %>

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
<Style type = "text/css">
. Style1
{
Width: 100%;
}
</Style>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: ScriptManager ID = "ScriptManager1" runat = "server">
</Asp: ScriptManager>
<Asp: UpdatePanel ID = "UpdatePanel1" runat = "server">
<ContentTemplate>
<Asp: Timer ID = "Timer1" runat = "server" ontick = "Timer1_Tick">
</Asp: Timer>
<Asp: Label ID = "Label1" runat = "server" Text = "Label"> </asp: Label>
</ContentTemplate>
</Asp: UpdatePanel>
</Div>
</Form>
</Body>
</Html>

 

Post-renewal generation:

Using System;
Using System. Collections;
Using System. Configuration;
Using System. Data;
Using System. Linq;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. HtmlControls;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Xml. Linq;
Using System. Data. SqlClient;
Using System. Net. Mail;

Public partial class MailPJQGD: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{

}
// Public void SendMail (string strSmtpServer, string UserName, string Password, string strFrom, string strto, string strSubject, string strBody)

Public void SendSMTPEMail (string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
{
// Generate a client object for sending the email using Smtp;
System. Net. Mail. SmtpClient Client = new SmtpClient (strSmtpServer );
Client. Port = 25;
Client. usedefacrecredentials = false; // The default credential used to authenticate the current logon user.
// Client. Credentials = new System. Net. NetworkCredential (UserName, Password );
Client. Credentials = new System. Net. NetworkCredential (strFrom, strFromPass); // contains the secret name and secret;
Client. DeliveryMethod = SmtpDeliveryMethod. Network;
System. Net. Mail. MailMessage message = new MailMessage (strFrom, strto, strSubject, strBody );
Message. BodyEncoding = System. Text. Encoding. UTF8;
Message. IsBodyHtml = true;
Client. Send (message); // Send
}
Public static int iii = 0;
Protected void timereffectick (object sender, EventArgs e)
{
If (iii = 0)
{
String day = DateTime. Now. Day. ToString ();
If (day = "15 ")
{
String server = "192.168.2.8"; // defines the server address.
String sendEmail = "mis10@tjpcb.com"; // defines the sender's mailbox
String sendEmailPassWord = "123456"; // defines the sender's email password.
String getEmail = "lishuanzhu@tjpcb.com"; // get the recipient's email address
String titleEmail = "the accessory ticket must be provided explicitly." // defines the subject of the email.
String context = ""; // defines the mail content
String str = "server = 192.168.3.127; database = FlowMaster; UId = sa; password = bruce_zhao888418 ";
SqlConnection sqlcon = new SqlConnection (str );
Sqlcon. Open ();
String sqlstr = @"
Select distinct * from (
Select nows, ApplyerDeptName, pinming1, norm1, Material1, quantity1
From WLQGD_View
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and Status = '20160301' and
(Quantity1 <> '0' and quantity1 is not null and quantity1 <> ''and pinming1 <>'' and pinming1 is not null)
Union all
Select nows, ApplyerDeptName, pinming2, norm2, material, quantity2
From WLQGD_View
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and Status = '20160301' and
(Quantity2 <> '0' and quantity2 is not null and quantity2 <> ''and pinming2 <>'' and pinming2 is not null)
Union all
Select nows, ApplyerDeptName, pinming3, norm3, materi_3, quantity3
From WLQGD_View
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and Status = '20160301' and
(Quantity3 <> '0' and quantity3 is not null and quantity3 <> ''and pinming3 <>'' and pinming3 is not null)
Union all
Select nows, ApplyerDeptName, pinming4, norm4, Material4, quantity4
From WLQGD_View
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and Status = '20160301' and
(Quantity4 <> '0' and quantity4 is not null and quantity4 <> ''and pinming4 <>'' and pinming4 is not null)
Union all
Select nows, ApplyerDeptName, pinming5, norm5, Material5, quantity5
From WLQGD_View
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and Status = '20160301' and
(Quantity5 <> '0' and quantity5 is not null and quantity5 <> ''and pinming5 <>'' and pinming5 is not null)
Union all
Select nows, ApplyerDeptName, pinming6, norm6, Material6, quantity6
From WLQGD_View
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and Status = '20160301' and
(Quantity6 <> '0' and quantity6 is not null and quantity6 <> ''and pinming6 <>'' and pinming6 is not null)
Union all
Select nows, ApplyerDeptName, pinming7, norm7, Material7, quantity7
From WLQGD_View
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and status = '20160301' and
(Quantity7 <> '0' and quantity7 is not null and quantity7 <> ''and pinming7 <>'' and pinming7 is not null)
Union all
Select nows, applyerdeptname, pinming8, norm8, material8, quantity8
From wlqgd_view
Where applydatetime> = '2017-8-15 'and applydatetime <= '2017-9-14' and status = '20160301' and
(Quantity8 <> '0' and quantity8 is not null and quantity8 <> ''and pinming8 <>'' and pinming8 is not null)
) A order by nows ASC

";
Sqldataadapter sqlda = new sqldataadapter (sqlstr, sqlcon );
Dataset DS = new dataset ();
String tablestr = @ "<Table border = '0' cellpadding = '0' cellspacing = '0' style = 'font-family:; font-size: 14px; color: blue; '>
<Tr> <TD> hello, </TD> </tr>
<Tr> <TD> & nbsp; the following values are from to. Please provide a clear metric for the quantity listed in the ticket. Thank you! </TD> </tr>
</Table> <br/> <p> </P> <Table border = '0' cellpadding = '0' cellspacing = '0' style = 'font-family:; font-size: 14px; color: Blue; 'align = 'left'>
<Tr> <td> hardware and software organization <br/> presented </td> </tr>
</Table> <br/> <p> </p> <table border = '1' cellpadding = '0' cellspacing = '0' align = 'left'>
<Tr style = 'color: # FFFFFF; background-color: # FF9900; 'align = 'center'> <td> filling time </td> <td> Application Form </td> <td> product name </td> <td> Specification </td> <td> brand Material Quality </td> <td> quantity required </td> </tr> ";
Sqlda. Fill (ds );
If (ds. Tables [0]. Rows. Count> 0)
{
For (int I = ds. Tables [0]. Rows. Count; I> 0; I --)
{
String nows = ds. Tables [0]. Rows [I-1] [0]. ToString ();
String ApplyDepName = ds. Tables [0]. Rows [I-1] [1]. ToString ();
String pingming1 = ds. Tables [0]. Rows [I-1] [2]. ToString ();
String norm1 = ds. Tables [0]. Rows [I-1] [3]. ToString ();
String Material1 = ds. Tables [0]. Rows [I-1] [4]. ToString ();
String quantity1 = ds. Tables [0]. Rows [I-1] [5]. ToString ();
TableStr + = @"
<Tr align = 'center'> <td style = 'font-size: 12px; width: 200px; '> "+ nows + @" </td> <td style = 'font-size: 12px; width: 200px; '> "+ ApplyDepName + @" </td> <td style = 'font-size: 12px; width: 200px; '> "+ pingming1 + @" </td> <td style = 'font-size: 12px; width: 200px;'> "+ norm1 + @" & nbsp; </td> <td style = 'font-size: 12px; width: 200px; '> "+ Material1 + @" & nbsp; </td> <td style = 'font-size: 12px; width: 200px; '> "+ quantity1 + @" </td> </tr>
";
}
TableStr + = @ "</table> ";
SendSMTPEMail (server, sendEmail, sendEmailPassWord, getEmail, "the number of requests required for the accessory ticket is displayed in", tableStr );
SendSMTPEMail (server, sendEmail, sendEmailPassWord, "mis12@tjpcb.com", titleEmail, tableStr );
SendSMTPEMail (server, sendEmail, sendEmailPassWord, "qianshengjun@tjpcb.com", titleEmail, tableStr );
}
}
Iii ++;
Label1.Text = "success ";
}
}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.