資源簡介
smtp 發送郵件給多個用戶,帶附件,測試本機smtp服務是否正常.附帶 excel導出報表,在發送郵件

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?Microsoft.Office.Interop.Owc11;
using?System.Net.Mail;
namespace?mailtest
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????//?創建附件
????????private?void?btnInclude_Click(object?sender?EventArgs?e)
????????{
????????????//?創建excel路徑
????????????string?path?=?Application.StartupPath.ToString();
????????????//?實例化execl中的一張表????????????
????????????Microsoft.Office.Interop.Owc11.SpreadsheetClass?xlsheet?=?new?Microsoft.Office.Interop.Owc11.SpreadsheetClass();
????????????xlsheet.ActiveSheet.Cells[1?1]?=?“這是一個測試用的excel“;
????????????//?列寬自適應
????????????xlsheet.Cells.EntireColumn.AutoFit();
????????????//?設置路徑和名稱
????????????string?strTime?=?DateTime.Now.Year.ToString()?+?DateTime.Now.Month.ToString()?+?DateTime.Now.Day.ToString()?+
?????????????????????????????DateTime.Now.Hour.ToString()?+?DateTime.Now.Minute.ToString()?+?DateTime.Now.Second.ToString()?+
?????????????????????????????DateTime.Now.Millisecond.ToString();
????????????path?+=?“\\“?+?strTime?+?“.xls“;
????????????//?導出excel表格
????????????xlsheet.Export(path?Microsoft.Office.Interop.Owc11.SheetExportActionEnum.ssExportActionNone?Microsoft.Office.Interop.Owc11.SheetExportFormat.ssExportxmlSpreadsheet);
????????????this.tbxInclude.Text?=?path;
????????}
????????//?發送郵件
????????private?void?btnSend_Click(object?sender?EventArgs?e)
????????{
????????????bool?flg?=?true;
????????????string?msg?=?““;
????????????//?輸入判斷
????????????if?(this.tbxName.Text?==?““)
????????????{
????????????????flg?=?false;
????????????????msg?=?“用戶名不能為空“;
????????????????this.tbxName.Focus();
????????????}
????????????else?if?(this.tbxPassWord.Text?==?““)
????????????{
????????????????flg?=?false;
????????????????msg?=?“密碼不能為空“;
????????????????this.tbxPassWord.Focus();
????????????}
????????????else?if?(this.tbxPassWord.Text?==?““)
????????????{
????????????????flg?=?false;
????????????????msg?=?“密碼不能為空“;
????????????????this.tbxPassWord.Focus();
????????????}
????????????else?if?(this.tbxSMTP.Text?==?““)
????????????{
????????????????flg?=?false;
????????????????msg?=?“SMTP不能為空“;
????????????????this.tbxSMTP.Focus();
????????????}
????????????else?if?(this.tbxPort.Text?==?““)
????????????{
????????????????flg?=?false;
????????????????msg?=?“端口號不能為空“;
????????????????this.tbxPort.Focus();
????????????}
????????????else?if?(this.tbxSendAddress.Text?==?““)
????????????{
????????????????flg?=?false;
????????????????msg?=?“發送地址不能為空“;
????????????????this.tbxSendAddress.Focus();
????????????}
????????????else?if?(this.tbxGetAddress.Text?==?““)
????????????{
????????????????flg?=?false;
????????????????msg?=?“收件人地址不能為空“;
????????????????this.tbxGetAddress.Focus
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5448??2010-09-15?10:39??mailtest.csproj
?????文件????????500??2010-09-15?08:48??Program.cs
?????文件??????15872??2010-09-15?10:53??bin\Debug\mailtest.exe
?????文件????????117??2010-09-15?10:26??bin\Debug\mailtest.exe.config
?????文件????????117??2010-09-15?10:26??bin\Debug\mailtest.vshost.exe.config
?????文件????????490??2010-03-17?22:39??bin\Debug\mailtest.vshost.exe.manifest
?????文件?????141928??2007-10-10?09:48??bin\Debug\Microsoft.Office.Interop.Graph.dll
?????文件?????223800??2007-10-10?09:48??bin\Debug\office.dll
?????文件?????141928??2007-10-10?09:48??obj\Microsoft.Office.Interop.Graph.dll
?????文件?????223800??2007-10-10?09:48??obj\office.dll
?????文件???????2152??2010-09-15?08:48??obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6705??2010-09-15?14:36??obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????494??2010-09-15?10:51??obj\x86\Debug\GenerateResource-ResGen.read.1.tlog
?????文件????????510??2010-09-15?10:51??obj\x86\Debug\GenerateResource-ResGen.write.1.tlog
?????文件??????????2??2010-09-15?10:51??obj\x86\Debug\GenerateResource.read.1.tlog
?????文件??????????2??2010-09-15?10:51??obj\x86\Debug\GenerateResource.write.1.tlog
?????文件???????1391??2010-09-15?14:37??obj\x86\Debug\mailtest.csproj.FileListAbsolute.txt
?????文件????????944??2010-09-15?14:36??obj\x86\Debug\mailtest.csproj.ResolveComReference.cache
?????文件??????15872??2010-09-15?10:53??obj\x86\Debug\mailtest.exe
?????文件????????180??2010-09-15?10:51??obj\x86\Debug\mailtest.Form1.resources
?????文件??????26112??2010-09-15?10:53??obj\x86\Debug\mailtest.pdb
?????文件????????180??2010-09-15?10:39??obj\x86\Debug\mailtest.Properties.Resources.resources
?????文件???????4608??2010-09-15?10:50??obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件???????1452??2010-09-15?08:48??Properties\AssemblyInfo.cs
?????文件???????2840??2010-09-15?10:26??Properties\Resources.Designer.cs
?????文件???????5612??2010-09-15?08:48??Properties\Resources.resx
?????文件???????1087??2010-09-15?10:26??Properties\Settings.Designer.cs
?????文件????????249??2010-09-15?08:48??Properties\Settings.settings
?????文件????????117??2010-09-15?10:26??app.config
?????文件???????5956??2010-09-15?10:55??Form1.cs
............此處省略12個文件信息
- 上一篇:RFID防碰撞算法論文
- 下一篇:操作系統實驗報告哲學家就餐問題、讀者寫入者問題
評論
共有 條評論