2017-04-24 28 views
1
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 

上述工作正常。但是當我嘗試向圖像添加一些變量時,出現以下錯誤vba外觀嵌入圖像變量

錯誤!文件名未指定。

這裏是嘗試添加一個變量時,我的代碼:

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 

任何想法,爲什麼出現這種情況?

回答

1

閉上你的單引號(如何沒有它做這個工作?)

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

所以其他HTML變得

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

感謝,didnt甚至注意到這一點... – danyo