当前位置:网站首页>【博主推荐】C# Winform定时发送邮箱(附源码)
【博主推荐】C# Winform定时发送邮箱(附源码)
2022-07-06 09:13:00 【xcLeigh】
【博主推荐】C# Winform定时发送邮箱(附源码)
C# WinForm+Oracle+Email
1.支持对oracle数据定时查询,然后把查询结果发送邮箱;
2.灵活可配置,日志目录,数据库相关连接,展示的字段,展示的格式,发送的邮箱,表格的风格等;
3.可以在此基础上,支持扩展,定时查询数据(任何数据库),发送邮箱(短信);
窗体风格

1.支持最小化,关闭隐藏任务栏;
2.邮箱和数据库配置好了,开始线程,执行任务;
3.输出每次处理数据日志
- 窗体最小化

窗体代码
public ToDataEmail()
{
InitializeComponent();
//默认窗体最大化
//this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
SysFinalUtil.appLog = txtSysLog.Text + "log";
SysFinalUtil.appLog2 = txtSysLog.Text;
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
#region 线程开始结束
private void btnStart_Click(object sender, EventArgs e)
{
//短信接收线程
WriteFileUtil.WriteFileLog("---------------------进入定时查询数据发送邮箱", "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("---------------------关闭数据线程", "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("---------------------退出程序", "log");
nfiLow.Visible = false;
System.Environment.Exit(0);//所有线程退出
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("清空完毕!");
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
else
{
MessageBox.Show("清空异常!");
this.txtMess.Text = WriteFileUtil.ReadTxt();
}
}
运行文件

双击XcSharpApp.exe运行
源码地址
边栏推荐
- Use of dataset of pytorch
- Isn't there anyone who doesn't know how to write mine sweeping games in C language
- Pytorch RNN actual combat case_ MNIST handwriting font recognition
- Advantages and disadvantages of evaluation methods
- Export virtual machines from esxi 6.7 using OVF tool
- [unity] simulate jelly effect (with collision) -- tutorial on using jellysprites plug-in
- API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T
- Pytoch LSTM implementation process (visual version)
- [BMZCTF-pwn] 12-csaw-ctf-2016-quals hungman
- 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
猜你喜欢

CSDN question and answer module Title Recommendation task (II) -- effect optimization

CSDN博文摘要(一) —— 一个简单的初版实现

Download and installation of QT Creator

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
![[reading notes] rewards efficient and privacy preserving federated deep learning](/img/c3/5e88277b5024885d5ceeaa0de14b27.jpg)
[reading notes] rewards efficient and privacy preserving federated deep learning

A trip to Macao - > see the world from a non line city to Macao

ZABBIX introduction and installation

MySQL23-存儲引擎

Mysql34 other database logs
![[C language] deeply analyze the underlying principle of data storage](/img/d6/1c0cd38c75da0d0cc1df7f36938cfb.png)
[C language] deeply analyze the underlying principle of data storage
随机推荐
Mysql21 user and permission management
Solve the problem that XML, YML and properties file configurations cannot be scanned
Esp8266 at+cipstart= "", "", 8080 error closed ultimate solution
MySQL19-Linux下MySQL的安装与使用
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd0 in position 0成功解决
Record the first JDBC
Pytorch LSTM实现流程(可视化版本)
Global and Chinese market of wafer processing robots 2022-2028: Research Report on technology, participants, trends, market size and share
Use JUnit unit test & transaction usage
MySQL23-存储引擎
February 13, 2022 - Maximum subarray and
CSDN question and answer tag skill tree (II) -- effect optimization
MySQL29-数据库其它调优策略
Mysql27 index optimization and query optimization
Other new features of mysql18-mysql8
Development of C language standard
MNIST implementation using pytoch in jupyter notebook
Postman environment variable settings
windows下同时安装mysql5.5和mysql8.0
[untitled]