通过outlook和html正文发送的嵌入图像不会显示在智能手机上
本文关键字:图像 显示 智能手机 html outlook 正文 通过 | 更新日期: 2023-09-27 18:28:10
我在网上搜索了很多,但找不到任何解决这个问题的方法。我的桌面应用程序需要通过用户outlook发送电子邮件。除了嵌入的图像在智能手机上丢失(在iphone和少数安卓手机上进行了测试)之外,一切都正常工作。也在本地网络之外的outlook客户端上进行了测试(我之所以提到这一点,是因为html图像的"src"在发送方的本地网络上),并且一切都正常工作(我使用"cid"作为路径),所以问题可能不是图像的路径。
以下是我的测试代码的重要部分:
Public Sub Test()
Dim file As String = "''netapp2'Public'All'INTERNET PROJECTS'Pf-PMS'jonathana'DIVISION REPORT 25-12-2015(2)'DIVISION REPORT 25-12-2015-04-58-45.xlsm"
Dim filetosave As String = "''netapp2'Public'All'INTERNET PROJECTS'Pf-PMS'jonathana'DIVISION REPORT 25-12-2015(4)'IMAGES"
Dim a() As String = {filetosave & "'backlog.png", filetosave & "'Teams.png", filetosave & "'q.png"}
Dim b = "<div>" _
& "<p>" _
& "text*text*text " & Now.ToString & "<br/><br/>" & "text*text*text" _
& "<br/>" _
& "text*text*text" _
& "<br/>" _
& "text*text*text" _
& "<br/>" _
& "<br/>" _
& "<u><b>text*text*text</u></b> " _
& "<br/>" _
& "<img alt='BACKLOG TABLE' hspace=0 src='cid:backlog.png' align=baseline border=0> " _
& "<br/>" _
& "</p>" _
& "</div> " _
& "<br/>" _
& "<br/>" _
& "<div> " _
& "<p>" _
& "<u><b>text*text*text </u></b>" _
& "<br/>" _
& "<IMG alt='ORANGE TEAMS DISTRIBUTION' hspace=0 src='cid:Teams.png' align=baseline border=0> " _
& "<br/>" _
& "</p>" _
& "</div> " _
& "<br/>" _
& "<br/>" _
& "<div> " _
& "<p>" _
& "<u><b>text*text*text </u></b>" _
& "<br/>" _
& "<IMG alt='DISTRIBUTION' hspace=0 src='cid:q.png' align=baseline border=0> " _
& "<br/>" _
& "</p>" _
& "</div> " _
& "<br/>"
Dim subject As String = text*text*text"
SendHtmlEmailMessegeWithMultipleAtachments(subject, b, GeneralInformation.InfoStructue.UserEmail & ";XXX@012.net.il", "", "DIVISION_REPORT", a)
End Sub
Sub SendHtmlEmailMessegeWithMultipleAtachments(ByVal sSubject As String, ByVal sBody As String, ByVal sTo As String, ByVal sCC As String, _
ByVal sDisplayname As String, Optional ByVal sFilename() As String = Nothing)
Try
Dim oApp As Interop.Outlook._Application
oApp = New Interop.Outlook.Application
Dim oMsg As Interop.Outlook._MailItem
oMsg = oApp.CreateItem(Interop.Outlook.OlItemType.olMailItem)
oMsg.Subject = sSubject
oMsg.To = sTo
oMsg.CC = sCC
oMsg.HTMLBody = "<html><body dir=RTL>" & sBody & "</body></html>"
Dim strN As String = sDisplayname
If sFilename.Length > 0 Then
Dim sBodyLen As Integer = Int(sBody.Length)
Dim oAttachs As Interop.Outlook.Attachments = oMsg.Attachments
Dim oAttach As Interop.Outlook.Attachment
For Each itm In sFilename
oAttach = oAttachs.Add(itm.ToString)
Next
End If
oMsg.Save()
oMsg.Send()
oApp = Nothing
oMsg = Nothing
IsOpen = Nothing
Catch ex As Exception
MsgBox("ERROR:" & ex.ToString, vbCritical + vbMsgBoxRight, "ERROR")
End Try
必须将PR_ATTACH_CONTENT_ID属性设置为与HTML正文中图像的cid属性匹配的值。
oAttach = oAttachs.Add(itm.ToString)
oAttach.PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x3712001F", "backlog.png'