0
您好,我正在使用SendGridMessage()對象與VB.net通過SendGrid SMTP服務器發送電子郵件。
我有我要在郵件正文發送.mht文件...正文電子郵件中發送mht文件
我知道這是可能在郵件正文中發送純HTML,但是當我讀了MHT文件,並把它放在郵件正文,似乎都搞砸這樣的:
,我想看看它是這樣的:
這是我的代碼:
Dim myMsg As New SendGridMessage()
myMsg.AddTo("[email protected]")
myMsg.From = New MailAddress(ApiEmail, ApiUserName)
myMsg.Subject = "Test with MHT file"
myMsg.Html = ""
Dim fso As New FileSystemObject
Dim ts As TextStream
'Open file.
ts = fso.OpenTextFile(sPath)
'Loop while not at the end of the file.
Do While Not ts.AtEndOfStream
myMsg.Html += ts.ReadLine
Loop
'Close the file.
ts.Close()
Dim credentials = New NetworkCredential(ApiUser, ApiKey)
Dim transportWeb = New Web(credentials)
transportWeb.DeliverAsync(myMsg)