我需要发送一封电子邮件,其中包含一个在每个单元格中都有变量值的表格。我可以使用任何方法(通过电子邮件的 html、excel/word 表等)来做到这一点。唯一的障碍是由于 Emailer 程序和 System.Net.Mail 导入的限制,它必须是一个字符串。
这是我到目前为止所拥有的:
Imports DelayEmailer.DelayTrackerWs
Imports System.Configuration
Public Class DelayEmailer
Public Shared Sub Main()
Dim ws As New DelayTrackerWs.DelayUploader
Dim delays As DelayTrackerWs.Delay()
Dim emailer As New Emailer()
Dim delaystring As String
delays = ws.SearchDelaysDate(DelayTrackerWs.AreaEnum.QT, DelayTrackerWs.UnitEnum.QT, Now.AddDays(-1), Now)
delaystring = "Delays" & vbNewLine
delaystring &= "Facilty Start Time Status Category Reason Comment"
For i = 0 To delays.Length - 1
delaystring &= vbNewLine & delays(i).Facility & " "
delaystring &= FormatDateTime(delays(i).DelayStartDateTime, DateFormat.ShortDate) & " "
delaystring &= FormatDateTime(delays(i).DelayStartDateTime, DateFormat.ShortTime) & " "
'delaystring &= delays(i).DelayDuration & " "
delaystring &= delays(i).Status & " "
delaystring &= delays(i).CategoryCode & " "
delaystring &= delays(i).ReasonCode & " "
delaystring &= delays(i).Comment
Next
emailer.Send(ConfigurationManager.AppSettings("EmailList"), "delays", delaystring)
End Sub
如您所见,如果每个 delays(i) 的值相同,我目前只有一堆串联的字符串。另一个问题是,这需要通过移动设备轻松查看,并且使用字符串,它会包装并且变得非常不可读。这里的一张桌子应该可以解决这个问题。