vba 带有变量的 outlook 嵌入图像
vba outlook embed image with variables
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
以上工作正常。但是当我尝试向图像添加一些变量时,出现以下错误
Error! Filename not specified.
这是我尝试添加变量时的代码:
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
知道为什么会这样吗?
关闭你的单引号(没有它这是如何工作的?)
"<html><img src='http://example.com/pixel.php></html>"
^
所以另一个HTML变成了
"<html><img src='http://example.com/pixel.php?to=" + mailItem.To + "'></html>"
^
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
以上工作正常。但是当我尝试向图像添加一些变量时,出现以下错误
Error! Filename not specified.
这是我尝试添加变量时的代码:
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
知道为什么会这样吗?
关闭你的单引号(没有它这是如何工作的?)
"<html><img src='http://example.com/pixel.php></html>"
^
所以另一个HTML变成了
"<html><img src='http://example.com/pixel.php?to=" + mailItem.To + "'></html>"
^