当前位置:网站首页>[recommended by bloggers] C WinForm regularly sends email (with source code)
[recommended by bloggers] C WinForm regularly sends email (with source code)
2022-07-06 10:53:00 【xcLeigh】
List of articles
【 Bloggers recommend 】C# Winform Send email regularly ( Source code attached )
C# WinForm+Oracle+Email
1. Support for oracle Data regular query , Then send the query results to the email ;
2. Flexible and configurable , Log directory , Database related connections , The fields shown , The format of the presentation , Email sent , Form style, etc ;
3. On this basis , Support extended , Query data regularly ( Any database ), Send email ( SMS );
Form style
1. Support for minimization , Close hidden taskbar ;
2. The mailbox and database are configured , Start thread , Perform tasks ;
3. Output each processing data log
- Minimize the form
Form code
public ToDataEmail()
{
InitializeComponent();
// Default form maximization
//this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
SysFinalUtil.appLog = txtSysLog.Text + "log";
SysFinalUtil.appLog2 = txtSysLog.Text;
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
#region Thread start end
private void btnStart_Click(object sender, EventArgs e)
{
// SMS receiving thread
WriteFileUtil.WriteFileLog("--------------------- Enter the regular query data sending mailbox ", "log");
EmailData sh = new EmailData();
EmailData.SysEmailName = txtSysEmailName.Text;
EmailData.SysEmailPass = txtSysEmailPass.Text;
EmailData.UserEmailName = txtUserEmailName.Text;
EmailData.SysEmailTitle = txtSysEmailTitle.Text;
EmailData.SysExecuteTime = int.Parse(txtSysExecuteTime.Text);
DBHelper.OracleDBHelper.linkConn = this.txtOracleLjc.Text;
EmailData.OracleSql = txtOracleSql.Text;
EmailData.OracleField = txtOracleField.Text;
EmailData.OracleFieldDetail = txtOracleFieldDetail.Text;
SysFinalUtil.appLog = txtSysLog.Text+"log";
SysFinalUtil.appLog2 = txtSysLog.Text;
string color = "1";
string style = "1";
if (rbColor1.Checked) { color = "1"; }
else if (rbColor2.Checked) { color = "2"; }
else if (rbColor3.Checked) { color = "3"; }
if (rbStyle1.Checked) { style = "1"; }
else if (rbStyle2.Checked) { style = "2"; }
EmailData.SysColor = color;
EmailData.SysStyle = style;
glo2.GlobalValue2.Email_RecvHandle = new Thread(sh.Rev_RunEmail);
glo2.GlobalValue2.Email_RecvHandle.Start();
this.btnClose.Enabled = true;
this.btnStart.Enabled = false;
}
private void btnClose_Click(object sender, EventArgs e)
{
glo2.GlobalValue2.Email_RecvHandle.Abort();
this.btnStart.Enabled = true;
this.btnClose.Enabled = false;
WriteFileUtil.WriteFileLog("--------------------- Close the data thread ", "log");
}
#endregion
private void ToDataEmail_Load(object sender, EventArgs e)
{
if (glo2.GlobalValue2.Email_RecvHandle == null)
{
this.btnStart.Enabled = true;
this.btnClose.Enabled = false;
}
else
{
this.btnClose.Enabled = true;
this.btnStart.Enabled = false;
}
}
private void ToDataEmail_FormClosed(object sender, FormClosedEventArgs e)
{
this.WindowState = FormWindowState.Minimized;
this.Hide();
return;
}
private void ToDataEmail_FormClosing(object sender, FormClosingEventArgs e)
{
this.WindowState = FormWindowState.Minimized;
this.Hide();
e.Cancel = true;
return;
}
private void nfiLow_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
//this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
private void tsmixcSharp_Click(object sender, EventArgs e)
{
Process.Start("https://blog.csdn.net/weixin_43151418");
}
private void tsmiShow_Click(object sender, EventArgs e)
{
this.Show();
//this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
private void tsmiVis_Click(object sender, EventArgs e)
{
this.Hide();
}
private void tsmiExit_Click(object sender, EventArgs e)
{
//WriteFileUtil.WriteFileLog("--------------------- Exit procedure ", "log");
nfiLow.Visible = false;
System.Environment.Exit(0);// All threads exit
this.Close();
this.Dispose();
System.Windows.Forms.Application.Exit();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
private void tsmiTxtLoad_Click(object sender, EventArgs e)
{
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
private void tsmiTxtClear_Click(object sender, EventArgs e)
{
if (WriteFileUtil.clearTxt())
{
//MessageBox.Show(" Emptying complete !");
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
else
{
MessageBox.Show(" Empty exception !");
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
}
Run the file
double-click XcSharpApp.exe function
Source code address
【 Bloggers recommend 】C# Winform Send email regularly ( Source code attached )
边栏推荐
- Case identification based on pytoch pulmonary infection (using RESNET network structure)
- CSDN question and answer tag skill tree (II) -- effect optimization
- [programmers' English growth path] English learning serial one (verb general tense)
- 虚拟机Ping通主机,主机Ping不通虚拟机
- February 13, 2022-2-climbing stairs
- MySQL27-索引优化与查询优化
- Use of dataset of pytorch
- Unicode decodeerror: 'UTF-8' codec can't decode byte 0xd0 in position 0 successfully resolved
- MySQL20-MySQL的数据目录
- CSDN博文摘要(一) —— 一个简单的初版实现
猜你喜欢
MySQL21-用戶與權限管理
Esp8266 at+cipstart= "", "", 8080 error closed ultimate solution
Mysql24 index data structure
Windows cannot start the MySQL service (located on the local computer) error 1067 the process terminated unexpectedly
Postman uses scripts to modify the values of environment variables
Generate PDM file from Navicat export table
Valentine's Day is coming, are you still worried about eating dog food? Teach you to make a confession wall hand in hand. Express your love to the person you want
Installation and use of MySQL under MySQL 19 Linux
API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T
MySQL18-MySQL8其它新特性
随机推荐
MySQL 29 other database tuning strategies
Kubesphere - deploy the actual combat with the deployment file (3)
Mysql36 database backup and recovery
Postman uses scripts to modify the values of environment variables
导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
[paper reading notes] - cryptographic analysis of short RSA secret exponents
MySQL22-逻辑架构
Other new features of mysql18-mysql8
Mysql32 lock
@controller,@service,@repository,@component区别
C language advanced pointer Full Version (array pointer, pointer array discrimination, function pointer)
Generate PDM file from Navicat export table
Mysql22 logical architecture
MySQL18-MySQL8其它新特性
MySQL35-主从复制
C language string function summary
Global and Chinese market for intravenous catheter sets and accessories 2022-2028: Research Report on technology, participants, trends, market size and share
API learning of OpenGL (2001) gltexgen
CSDN问答模块标题推荐任务(一) —— 基本框架的搭建
CSDN问答标签技能树(五) —— 云原生技能树