我写了一个程序,其中燃气用量上报表中一行如果没有空字段,且有修改的话,会发一封邮件(包含报表)给一个邮箱,
但当这行再次被修改时,会显示报表文件已打开,先关闭之。
我应该如何在程序里在每次发完邮件后关闭这个报表
谢谢老师
S elect C ase e.DataCol.Name
Case “日期”,"天然气计划量","天然气实际量","天然气预测量","液化气购进量","液化气销售量","液化气库存量","天然气运行状态","液化气运行状态"
Dim dr As DataRow = e.DataRow
Dim Flag As Boolean = False
Dim nms() As String
nms = New String() {“日期”,"天然气计划量","天然气实际量","天然气预测量","天然气运行状态","液化气购进量","液化气销售量","液化气库存量","液化气运行状态"}
For Each nm As String In nms
If dr.IsNull(nm) Then
Flag = True
End If
Next
If Flag = False Then ‘如果所有字段都不为空
Dim Book As New XLS.Book(ProjectPath & "Attachments\燃气用量上报.xls")
Dim fl As String = ProjectPath & "Reports\燃气用量上报" & Format(dr("日期"),"yyyyMMdd") & ".xls"
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim m As New MailSender
m.Host = "smtp.qq.com"
m.EnableSsl = True '必须将EnableSsl属性设置为True
m.Account = "*****@qq.com"
m.Password = "czjmzfkpcrvccbec" '注意这不是QQ密码,是授权码
m.From = “******g@qq.com"
m.To = "******@qq.com"
m.Title = "每日燃气供热情况表" & Format(dr("日期"),"M.dd")
m.Content = "附件为每日燃气供热情况上报表,请查收."
m.AddAttachments(fl)
m.Send()
End If
End S elect