当前位置:网站首页>[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 )
边栏推荐
- Development of C language standard
- Kubesphere - deploy the actual combat with the deployment file (3)
- @Controller, @service, @repository, @component differences
- Nanny hand-in-hand teaches you to write Gobang in C language
- CSDN问答标签技能树(五) —— 云原生技能树
- MySQL21-用户与权限管理
- Google login prompt error code 12501
- CSDN问答标签技能树(二) —— 效果优化
- MySQL25-索引的创建与设计原则
- Mysql21 - gestion des utilisateurs et des droits
猜你喜欢

解决:log4j:WARN Please initialize the log4j system properly.

MySQL27-索引优化与查询优化

Export virtual machines from esxi 6.7 using OVF tool

Mysql27 - Optimisation des index et des requêtes

MySQL 20 MySQL data directory

Mysql22 logical architecture

CSDN问答模块标题推荐任务(一) —— 基本框架的搭建

数据库中间件_Mycat总结

In fact, the implementation of current limiting is not complicated

MySQL20-MySQL的数据目录
随机推荐
[unity] simulate jelly effect (with collision) -- tutorial on using jellysprites plug-in
Solution to the problem of cross domain inaccessibility of Chrome browser
MySQL23-存储引擎
MySQL32-锁
API learning of OpenGL (2001) gltexgen
Discriminant model: a discriminant model creation framework log linear model
虚拟机Ping通主机,主机Ping不通虚拟机
Mysql21 user and permission management
CSDN question and answer tag skill tree (II) -- effect optimization
Development of C language standard
Pytorch RNN actual combat case_ MNIST handwriting font recognition
Texttext data enhancement method data argument
Water and rain condition monitoring reservoir water and rain condition online monitoring
MySQL transaction log
Nanny hand-in-hand teaches you to write Gobang in C language
Postman uses scripts to modify the values of environment variables
Time in TCP state_ The role of wait?
Complete web login process through filter
Mysql21 - gestion des utilisateurs et des droits
[paper reading notes] - cryptographic analysis of short RSA secret exponents