2017-07-25 101 views
0

我正在使用Outlook腳本來轉發具有特定模板的電子郵件。我無法在<img scr=開始時添加徽標。使用HTML添加圖像

Public Sub FW(olItem As Outlook.MailItem) 

Dim olForward As Outlook.MailItem 
Set olForward = olItem.Forward 
Set olLogo = Outlook.Application 

If InStr(olItem.Subject, "AW:") Or InStr(olItem.Subject, "WG:") Or _ 
    InStr(olItem.Subject, "Re:") Or InStr(olItem.Subject, "FW:") Or _ 
    InStr(olItem.Subject, "Fwd:") Then 

    Stop 

ElseIf InStr(olItem.Subject, "CH1") Or InStr(olItem.Subject, "CH3") Then 

    Const Path = "T:\TEMP\" 
    Const Logo = "image001.jpg" 

    With olForward & olLogo 
     .Attachments.Add Path & Logo 
     .Subject = olItem.Subject 
     .BodyFormat = olFormatHTML 
     .HTMLBody = "<span style=color:#1F497D;font-size:11pt;font-family:calibri;>" & _ 
        "TEXT TUTAJ<BR><BR>" & _ 
        "TEXT TUTAJ<BR><BR>" & _ 
        "TEXT TUTAJ<BR>" & _ 
        "TEXT TUTAJ<BR><BR>" & _ 
        "<span style=color:#1F497D;font-size:9pt;font-family:arial;><b>" & _ 
        "TEXT TUTAJ</b><BR>" & _ 
        "TEXT TUTAJ<BR>" & _ 
        "<html><img scr=cid:" & Replace(Logo, " ", "%20") & "height=55 width=170></html><BR>" & _ 
        "TEXT TUTAJ" 
     .Display 
     .To = "" 
     .CC = "" 
     .Send 
    End With 

End If 


'// Clean up 
Set olItem = Nothing 
Set olForward = Nothing 
Set olLogo = Nothing 
End Sub 
+0

例如您周圍是否缺少CID引號 –

+0

怎麼會這樣?試圖添加它,只出現錯誤。 –

回答

0

想通了,應該看起來像這樣。

Public Sub FW(olItem As Outlook.MailItem) 

Dim olForward As Outlook.MailItem 
Set olForward = olItem.Forward 

If InStr(olItem.Subject, "AW:") Or InStr(olItem.Subject, "WG:") Or InStr(olItem.Subject, "Re:") Or _ 
InStr(olItem.Subject, "FW:") Or InStr(olItem.Subject, "Fwd:") Then 

    Stop 

ElseIf InStr(olItem.Subject, "CH1") Or InStr(olItem.Subject, "CH3") Then 

    With olForward 
     .Attachments.Add "C:\TEMP\logo.jpg", olByValue, 0 
     .Subject = olItem.Subject 
     .BodyFormat = olFormatHTML 
     .HTMLBody = "<span style=color:#1F497D;font-size:11pt;font-family:calibri;>" & _ 
        "TEXT TUTAJ<BR><BR>" & _ 
        "TEXT TUTAJ<BR><BR>" & _ 
        "TEXT TUTAJ<BR>" & _ 
        "TEXT TUTAJ</span><BR><BR>" & _ 
        "<span style=color:#000000;font-size:9pt;font-family:arial;>" & _ 
        "<b>TEXT TUTAJ</b><BR>" & _ 
        "TEXT TUTAJ<BR>" & _ 
        "<img src='cid:logo.jpg'" & "width='170' height='55'><BR>" & _ 
        "TEXT TUTAJ</span>" 
     .To = "" 
     .CC = "" 
     .Display 
     .Send 
    End With 

End If 


'// Clean up 
Set olItem = Nothing 
Set olForward = Nothing 

末次

+0

這只是單引號,但如果你想雙擊[我的答案](https://stackoverflow.com/a/45348575/3649914) –

0

看起來你缺少報價,把它們放在最簡單的方法是加倍的報價處理報價。

下面

.HTMLBody = "<span style=color:#1F497D;font-size:11pt;font-family:calibri;>" & _ 
        "TEXT TUTAJ<BR><BR>" & _ 
        "TEXT TUTAJ<BR><BR>" & _ 
        "TEXT TUTAJ<BR>" & _ 
        "TEXT TUTAJ</span><BR><BR>" & _ 
        "<span style=color:#000000;font-size:9pt;font-family:arial;>" & _ 
        "<b>TEXT TUTAJ</b><BR>" & _ 
        "TEXT TUTAJ<BR>" & _ 
        "<img src=""cid:logo.jpg""" & "width=""170"" height=""55""><BR>" & _ 
        "TEXT TUTAJ</span>"