You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

企业HTML邮件签名脚本Logo不显示问题求助(需CID方案)

解决Outlook HTML签名图片无法显示的问题

要让收件端正常显示签名里的图片,核心是把图片嵌入到签名专属的资源文件夹,而非使用本地绝对路径。以下是修改后的VBScript,同时修复了原脚本中的语法问题:

On Error Resume Next

'Setting up the script to work with the file system.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSysObj = CreateObject("Scripting.FileSystemObject")

'Connecting to Active Directory to get user’s data.
Set objSysInfo = CreateObject("ADSystemInfo")
Set UserObj = GetObject("LDAP://" & objSysInfo.UserName)
strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%")
SigFolder = StrAppData & "\Microsoft\Signatures\"
SigFileName = UserObj.sAMAccountName & "1"
SigFile = SigFolder & SigFileName & ".htm"
' 创建签名对应的资源文件夹
SigResourceFolder = SigFolder & SigFileName & "_files\"
If Not FileSysObj.FolderExists(SigResourceFolder) Then
    FileSysObj.CreateFolder(SigResourceFolder)
End If

'Setting placeholders for the signature.
strUserName = UserObj.sAMAccountName
strFullName = UserObj.displayname
strTitle = UserObj.title
strMobile = UserObj.mobile
strEmail = UserObj.mail
strCompany = UserObj.company
strOfficePhone = UserObj.telephoneNumber

'Setting global placeholders for the signature. Those values will be identical for all users - make sure to replace them with the right values!
' 原始图片的绝对路径
strCompanyLogoSrc = "file_location\image.jpg"
strFacebookIconSrc = "File Location\facebook.jpg"
strLinkedInIconSrc = "File Location\linkedin.jpg"
strInstagramIconSrc = "File Location\instagram.jpg"
strPinterestIconSrc = "File Location\Pinterest.jpg"
' 复制图片到资源文件夹,并定义相对路径
strCompanyLogo = "image.jpg"
strFacebookIcon = "facebook.jpg"
strLinkedInIcon = "linkedin.jpg"
strInstagramIcon = "instagram.jpg"
strPinterestIcon = "Pinterest.jpg"
' 复制图片
If FileSysObj.FileExists(strCompanyLogoSrc) Then
    FileSysObj.CopyFile strCompanyLogoSrc, SigResourceFolder & strCompanyLogo, True
End If
If FileSysObj.FileExists(strFacebookIconSrc) Then
    FileSysObj.CopyFile strFacebookIconSrc, SigResourceFolder & strFacebookIcon, True
End If
If FileSysObj.FileExists(strLinkedInIconSrc) Then
    FileSysObj.CopyFile strLinkedInIconSrc, SigResourceFolder & strLinkedInIcon, True
End If
If FileSysObj.FileExists(strInstagramIconSrc) Then
    FileSysObj.CopyFile strInstagramIconSrc, SigResourceFolder & strInstagramIcon, True
End If
If FileSysObj.FileExists(strPinterestIconSrc) Then
    FileSysObj.CopyFile strPinterestIconSrc, SigResourceFolder & strPinterestIcon, True
End If

strCompanyAddress1 = "Address"
strWebsite = "https://your-company-website.com"
strFacebook = "https://your-facebook-url.com"
strTwitter = "https://your-twitter-url.com"
strYouTube = "https://your-youtube-url.com"
strLinkedIn = "https://your-linkedin-url.com"
strInstagram = "https://your-instagram-url.com"
strPinterest = "https://your-pinterest-url.com"

'Creating HTM signature file for the user's profile, if the file with such a name is found, it will be overwritten.
Set CreateSigFile = FileSysObj.CreateTextFile (SigFile, True, True)

'Signature’s HTML code.
CreateSigFile.WriteLine "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"
CreateSigFile.WriteLine "<HTML><HEAD><TITLE>Email Signature</TITLE>"
CreateSigFile.WriteLine "<META content=""text/html; charset=utf-8"" http-equiv=""Content-Type"">"
CreateSigFile.WriteLine "</HEAD>"
CreateSigFile.WriteLine "<BODY style=""font-size: 10pt; font-family: Arial, sans-serif;"">"
CreateSigFile.Writeline "<table style=""width: 640px; font-size: 10pt; font-family: Arial, sans-serif;"" cellpadding=""0"" cellspacing=""0"">"
CreateSigFile.Writeline "<tbody>"
CreateSigFile.Writeline "<tr>"
CreateSigFile.Writeline "<td width=""130"" style=""font-size: 10pt; font-family: Arial, sans-serif; border-right: .5px solid; border-right-color: #404040; width: 115px; padding-right: 5px; vertical-align: middle;"" valign=""middle"" rowspan=""6""> <a href=""" & strWebsite & """ target=""_blank""> <img border=""0"" alt=""Logo"" width=""96"" style=""width:96px; height:97px; border:0;"" src=""" & strCompanyLogo & """"> </a>"
CreateSigFile.Writeline "</td>"
CreateSigFile.Writeline "<td>"
CreateSigFile.Writeline "<table cellpadding=""0"" cellspacing=""0"">"
CreateSigFile.Writeline "<tbody>"
CreateSigFile.Writeline "<tr>"
CreateSigFile.Writeline "<td style=""font-size: 10pt; color:#404040; font-family: Arial, sans-serif; width: 305px; padding-bottom: 15px; padding-left: 20px; vertical-align: top; line-height:25px;"" valign=""top"">"
CreateSigFile.Writeline "<strong><span style=""font-size: 14pt; font-family: Livory Bold, sans-serif; color:#404040;"">" & strFullName & "<br></span></strong>"
CreateSigFile.Writeline "<span style=""font-family: Livory Regular, sans-serif; font-size:12pt; font-style: italic; color:#404040;"">" & strTitle & "</span>"
CreateSigFile.Writeline "</td>"
CreateSigFile.Writeline "</tr>"
CreateSigFile.Writeline "<tr>"
CreateSigFile.Writeline "<td style=""font-size: 12pt; color:#404040; font-family: Livory Bold, sans-serif; padding-bottom: 0px; padding-top: 5px; padding-left: 20px; vertical-align: top;"" valign=""top"">"
CreateSigFile.Writeline "<span><span style=""color: #404040;""> <strong>email </strong></span><span style=""font-size: 12pt; font-family: Livory Regular, sans-serif; color:#404040;"">" & strEmail & "<br></span></span>"
CreateSigFile.Writeline "<span><span style=""color: #404040;""> <strong>phone </strong></span><span style=""font-family: Livory Regular, sans-serif; font-size:12pt; color:#404040;"">" & strOfficePhone & "</span>"
If NOT (strMobile = "") Then 
    CreateSigFile.Writeline "<span style=""font-family: Livory Bold, sans-serif; font-size:12pt; font-weight: bold; color:#404040;""> | mobile </span>"
    CreateSigFile.Writeline "<span style=""font-family: Livory Regular, sans-serif; font-size:12pt; color:#404040;"">" & strMobile & "</span>"
End If
CreateSigFile.Writeline "</td>"
CreateSigFile.Writeline "</tr>"
CreateSigFile.Writeline "<tr>"
CreateSigFile.Writeline "<td style=""font-size: 10pt; font-family: Arial, sans-serif; padding-bottom: 15px; padding-top: 0px; padding-left: 20px; vertical-align: top; color: #0079ac;"" valign=""top"">"
CreateSigFile.Writeline "<span style=""font-size: 12pt; font-family: Livory Regular, sans-serif; color: #404040;"">" & strCompanyAddress1 & "<br></span>"
CreateSigFile.Writeline "</td>"
CreateSigFile.Writeline "</tr>"
CreateSigFile.Writeline "<tr>"
CreateSigFile.Writeline "<td style=""font-size: 12pt; font-family: Jabara, sans-serif; padding-bottom: 15px; padding-top: 5px; padding-left: 20px; vertical-align: top; color: #404040;"" valign=""top"">"
CreateSigFile.Writeline "<a href=""" & strWebsite & """ target=""_blank"" rel=""noopener"" style=""text-decoration:none;""> <span style=""font-size: 12pt; font-family: Jabara, sans-serif; color: #404040;"">website url&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></a>"
CreateSigFile.Writeline "<a href=""" & strFacebook & """ target=""_blank"" rel=""noopener""> <img border=""0"" width=""25"" alt=""facebook icon"" style=""border:0; height:25px; width:25px; margin-left:25px"" src=""" & strFacebookIcon & """"> </a>&nbsp;"
CreateSigFile.Writeline "<a href=""" & strLinkedIn & """ target=""_blank"" rel=""noopener""> <img border=""0"" width=""25"" alt=""linkedin icon"" style=""border:0; height:25px; width:25px"" src=""" & strLinkedInIcon & """"> </a>&nbsp;"
CreateSigFile.Writeline "<a href=""" & strInstagram & """ target=""_blank"" rel=""noopener""> <img border=""0"" width=""27"" alt=""instagram icon"" style=""border:0; height:27px; width:27px"" src=""" & strInstagramIcon & """"> </a>&nbsp;"
CreateSigFile.Writeline "<a href=""" & strPinterest & """ target=""_blank"" rel=""noopener""> <img border=""0"" width=""25"" alt=""pinterest icon"" style=""border:0; height:25px; width:25px"" src=""" & strPinterestIcon & """"> </a>"
CreateSigFile.Writeline "</td>"
CreateSigFile.Writeline "</tr>"
CreateSigFile.Writeline "</tbody></table>"
CreateSigFile.Writeline "</td>"
CreateSigFile.Writeline "</tr>"
CreateSigFile.Writeline "</tbody></table>"
CreateSigFile.WriteLine "</BODY></HTML>"
CreateSigFile.Close

'Applying the signature in Outlook’s settings.
Set objWord = CreateObject("Word.Application")
Set objSignatureObjects = objWord.EmailOptions.EmailSignature

'Setting the signature as default for new messages.
objSignatureObjects.NewMessageSignature = SigFileName

'Setting the signature as default for replies & forwards.
objSignatureObjects.ReplyMessageSignature = SigFileName
objWord.Quit

修改说明:

  • 资源文件夹创建:自动生成签名对应的_files文件夹,Outlook会默认识别该文件夹内的图片为签名内嵌资源
  • 图片复制:将所有用到的图片从原始路径复制到资源文件夹,确保签名能稳定访问到图片文件
  • 路径修正:HTML中的图片src改为相对路径,替代原脚本的绝对本地路径,避免收件端无法访问发送方本地文件
  • 语法修复:修正了原脚本中引号不匹配、未定义变量、链接格式错误等问题
  • 结构优化:补全了HTML闭合标签,确保语法完整性

运行该脚本后,Outlook使用签名时会自动将图片作为内嵌附件发送,收件端即可正常显示所有签名图片。

内容的提问来源于stack exchange,提问作者HotelITGuy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 10:37:31