2017-04-24 2 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 

Ce qui précède fonctionne très bien. Mais quand j'essaye et ajoute quelques variables à l'image j'obtiens l'erreur suivantevba outlook intégrer l'image avec des variables

Erreur! Nom de fichier non spécifié

Voici mon code lorsque vous essayez d'ajouter une variable:

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 

Toutes les idées pourquoi cela se produit?

Répondre

1

Fermez votre guillemet simple (comment fait ce travail sans elle?)

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

Ainsi, l'autre HTML devient

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

Merci, na pas encore remarqué ce ... – danyo