【问题标题】:vba outlook embed image with variables带有变量的vba Outlook嵌入图像
【发布时间】:2017-04-24 16:10:31
【问题描述】:
Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector
    Dim mailItem As Outlook.MailItem = TryCast(Inspector.CurrentItem, Outlook.MailItem)
    If Not (mailItem Is Nothing) Then
        If mailItem.EntryID Is Nothing Then
            mailItem.Subject = "Test"
            mailItem.HTMLBody = mailItem.HTMLBody + "<html><img src='http://example.com/pixel.php></html>"
        End If
    End If
End Sub

以上工作正常。但是当我尝试向图像添加一些变量时,出现以下错误

错误!未指定文件名。

这是我尝试添加变量时的代码:

Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector
    Dim mailItem As Outlook.MailItem = TryCast(Inspector.CurrentItem, Outlook.MailItem)
    If Not (mailItem Is Nothing) Then
        If mailItem.EntryID Is Nothing Then
            mailItem.Subject = "Test"
            mailItem.HTMLBody = mailItem.HTMLBody + "<html><img src='http://example.com/pixel.php?to=" + mailItem.To + "></html>"
        End If
    End If
End Sub

你知道为什么会这样吗?

【问题讨论】:

    标签: vb.net post outlook add-in


    【解决方案1】:

    关闭你的单引号(没有它如何工作?)

    "<html><img src='http://example.com/pixel.php></html>"
                    ^
    

    所以其他的 HTML 变成了

    "<html><img src='http://example.com/pixel.php?to=" + mailItem.To + "'></html>"
                                                                        ^
    

    【讨论】:

      猜你喜欢
      • 2012-04-22
      • 1970-01-01
      • 1970-01-01
      • 2011-05-10
      • 1970-01-01
      • 2012-12-08
      • 2015-03-28
      • 2015-07-07
      • 2021-11-17
      相关资源
      最近更新 更多