計算器的答案,其中有更多的解釋(看看評論還)要留住從文本格式我能圖瞭解如何通過將文本區域導出爲文本文件,附加數據,然後使用導入它fso.OpenTextFile(「C:\ file.txt」,ForReading).ReadAll並使用 (html body pre) 進行格式化。這樣做,我能夠保留我的換行符,然後使用CDO.Message發送信息。
Const FOR_APPENDING = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTSO = objFSO.OpenTextFile("C:File.txt", FOR_APPENDING)
objTSO.WriteLine strDT & ":" & vbCrLf & Text2.value & vbCrLf
objTSO.Close()
Sub SendEmail(strSubject, strBody, strBody8, strFrom)
Const ForReading = 1
Dim fso, BodyText
Set fso = CreateObject("Scripting.FileSystemObject")
strMailbox = "Address<[email protected]>"
' E-Mail address being sent to
strSMTPServer = "SMTP Server"
' Primary SMTP relay server name
strSMTPPort = 25
' SMTP Port Number
Set objEmail = CreateObject("CDO.Message")
BodyText = fso.OpenTextFile("C:\file.txt",ForReading).ReadAll
With objEmail
.From = strFrom
.To = strMailbox
.Subject = strSubject
.HTMLBody = "<html><body><pre>" & strBody & "<BR>" & BodyText & "<BR>" &
strBody8 & "</pre></body></html>"
With .Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing" ) = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver" ) =
strSMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
strSMTPPort
.Update
End With
.Send ' Send the message!
End With
Set objEmail = Nothing
什麼輸出?什麼格式? –
我正在使用輸入到該textarea的文本爲使用CDO.Message發送的電子郵件創建文本輸出。 – Jason