- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
不久前,我一直在寻找一种灵活的方法来为不同类型的用户自动生成签名。我们的领域有多家公司,每个公司都有不同的需求。您在谷歌搜索时找到的默认脚本只是显示了如何创建基本签名。
下面的脚本进一步执行了几个步骤。首次启动 Microsoft Office 时,它会填写用户名和缩写。如果不存在 Outlook 配置文件,它将使用 PRF 文件设置 Outlook(您可以对笔记本电脑/平板电脑使用缓存,对台式机/服务器使用非缓存)。然后,它检查用户应该获取哪些签名,并使用签名文件、模板文件和事件目录中的用户信息中的信息构建它们。所有状态信息都写入应用程序事件日志(过滤器 WSH)。当签名文件更新时,签名将被重新应用。
我在这里发布整个脚本,希望其他人可能会发现它有用。请随意发表评论(当然也可以捐赠:-))。它适用于 Outlook 2000、2003、2010 和 2013(并且应该非常适合 future )。
最佳答案
在您的域中创建一个新的全局安全组。在我的示例中,我将使用 Signature-Marketing
和 Signature-HR
。
创建一个应用于这些组的新 GPO。将 Outlook.vbs
脚本放在 User\Policy\Windows\Scripts\Logon
中。
'\\MyDomain.local\SysVol\WGIT.local\Policies\{MyPolicyID}\User\Scripts\Logon\Outlook.vbs
On Error Resume Next
' ##### CHANGE THESE SETTINGS #####
setup_GroupPrefix = "Signature-"
setup_Path_SignatureVBS = "\\MyDomain.local\NETLOGON\Outlook\Signatures" 'Signatures with the same name as this group (+.VBS) will be searched within this
setup_Path_Template = "\\MyDomain.local\NETLOGON\Outlook\Templates" 'Signatures with the same name as this group (+.VBS) will be searched within this
setup_PRF_CacheOn = "\\MyDomain.local\NETLOGON\Outlook\PRF\Outlook_Cached.PRF"
setup_PRF_CacheOff = "\\MyDomain.local\NETLOGON\Outlook\PRF\Outlook_NotCached.PRF"
' ##### START OF SCRIPT #####
Set oShell = CreateObject("WScript.Shell")
Set oAD = CreateObject("ADSystemInfo")
Set oFile = CreateObject("Scripting.FileSystemObject")
Set oOutlook = CreateObject("Outlook.Application")
Set oUser = GetObject("LDAP://" & oAD.UserName)
'Quit if no outlook is present!
If oOutlook = false Then
oShell.LogEvent 1, "Signature script error. Outlook application object was not found."
Wscript.Quit
End If
'Quit if version is lower then 10
v = Split(oOutlook.Version, ".")
outlook_Version = v(0) & "." & v(1)
If cInt(v(0)) < 10 Then
oShell.LogEvent 1, "Signature script error. Outlook version " & outlook_Version & " is not supported."
Wscript.Quit
ElseIf (cInt(v(0)) >= 10) And (cInt(v(0)) < 15) Then
reg_DefaultProfile = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile"
Else
reg_DefaultProfile = "HKCU\Software\Microsoft\Office\" & outlook_Version & "\Outlook\DefaultProfile"
End If
'Check if Office's Userinfo already exists
t1 = oShell.RegRead("HKCU\Software\Microsoft\Office\Common\UserInfo\UserName")
If t1 = "" Then
'Add userinfo to registry.
oShell.RegWrite "HKCU\Software\Microsoft\Office\Common\UserInfo\UserName", oUser.FullName
oShell.RegWrite "HKCU\Software\Microsoft\Office\Common\UserInfo\UserInitials", oUser.sAMAccountName
oShell.RegWrite "HKCU\Software\Microsoft\Office\Common\UserInfo\Company", oUser.company
oShell.LogEvent 0, "Office userinformation was imported from AD."
End If
'Check for a default mail profile
t2 = oShell.RegRead(reg_DefaultProfile)
oShell.LogEvent 0, "Default profile (" & reg_DefaultProfile & ") said " & t2
If t2 = "" Then 'No default profile was found! Import PRF file!
'Detect mobile devices. Enabled cached outlook if there is a battery present
MobileDevice = false
Set oBattery = GetObject("Winmgmts:").ExecQuery("Select * from Win32_Battery")
For Each x in oBattery
MobileDevice = true
Next
'Import PRF location into registry
If MobileDevice Then
oShell.RegWrite "HKCU\Software\Microsoft\Office\" & outlook_Version & "\Outlook\Setup\ImportPRF", setup_PRF_CacheOn
oShell.LogEvent 0, "Office Outlook has been set-up with cache."
Else
oShell.RegWrite "HKCU\Software\Microsoft\Office\" & outlook_Version & "\Outlook\Setup\ImportPRF", setup_PRF_CacheOff
oShell.LogEvent 0, "Office Outlook has been set-up without cache."
End If
'Delete First-Run key to simulate a first run for outlook. (i.e. if a profile was configured and deleted)
oShell.RegDelete "HKCU\Software\Microsoft\Office\" & outlook_Version & "\Outlook\Setup\First-Run"
'Outlook does not need to be run.
'When a signature is being applied outlook will fire up it's initial boot and import the PRF settings.
'With this PRF applied the signature will be applied immediately
End If
'Compare users' group membership against available signature settings
Set GroupsOfUser = GetMembership(oUser.distinguishedName, null)
tGroups = Array()
For Each GroupName in GroupsOfUser.Items()
If Mid(GroupName, 1, Len(setup_GroupPrefix)) = setup_GroupPrefix Then
ReDim Preserve tGroups(UBound(tGroups) + 1)
tGroups(UBound(tGroups)) = GroupName
end if
Next
tGroups = SortArray(tGroups)
For Each group in tGroups
sFile = setup_Path_SignatureVBS & "\" & group & ".VBS"
If oFile.FileExists(sFile) = True Then 'File containing specific signature settings were found
Set Signature = new Defaults 'Use defaults
'Evaluate signature settings
executeGlobal oFile.openTextFile(sFile).readAll()
'Check if signature needs updating
sUpdate = false
If oFile.FileExists(Signature.sPath) Then
Set f = oFile.GetFile(Signature.sPath)
If Signature.sVersion > f.DateLastModified Then
sUpdate = true
End If
Else
sUpdate = true
End If
If sUpdate Then 'Apply signature
'Replace defaults with user specific data
If Not oUser.FullName = "" Then Signature.uName = oUser.FullName
If Not oUser.mail = "" Then Signature.uMail = LCase(oUser.mail)
If Not oUser.telephoneNumber = "" Then Signature.uPhone = oUser.telephoneNumber
If Not oUser.mobile = "" Then Signature.uCell = oUser.mobile
If Not oUser.facsimileTelephoneNumber = "" Then Signature.uFax = oUser.facsimileTelephoneNumber
If Not oUser.Title = "" Then Signature.uTitle = oUser.Title
If Not oUser.department = "" Then Signature.uDepartment = oUser.department
If Not oUser.info = "" Then Signature.uDisclaimer = oUser.info
'Build signature
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add()
Set oSelection = oWord.Selection
executeGlobal oFile.openTextFile(setup_Path_Template & "\" & Signature.sTemplate).readAll() 'Evaluate signatre template
Set oSelection = oDoc.Range()
'Add signature to outlook
oWord.EmailOptions.EmailSignature.EmailSignatureEntries.Add Signature.sName, oSelection
WScript.Sleep 200 'Give outlook the time to create the necessary files
'Set as default signature
If Signature.sCompanyNew = "*" OR StrComp(oUser.company, Signature.sCompanyNew, vbTextCompare) = 0 Then oWord.EmailOptions.EmailSignature.NewMessageSignature = Signature.sName
If Signature.sCompanyReply = "*" OR StrComp(oUser.company, Signature.sCompanyReply, vbTextCompare) = 0 Then oWord.EmailOptions.EmailSignature.ReplyMessageSignature = Signature.sName
'Closure
oDoc.Saved = True
oWord.Quit
WScript.Sleep 300 'Give work some time to clean up
'Logging
oShell.LogEvent 0, "Signature " & Signature.sName & " applied with success!"
Else
oShell.LogEvent 0, "Signature " & Signature.sName & " is up to date."
End If
Else
oShell.LogEvent 1, "Signature script error. Cannot load signature settings from " & sFile
End If
Next
' ##### CLASSES AND FUNCTIONS ######
Class Defaults
'Signature properties
Public sName 'Name of this signature
Public sVersion 'Apply signature if version date is newer then client's signature date
Public sTemplate 'Signature template to be used
Public sCompanyNew 'If the user company field matches this value it will be set as the default 'new' signature
Public sCompanyReply 'If the user company field matches this value it will be set as the default 'reply' signature
'Company properties
Public cName
Public cStreet
Public cBox
Public cPostal
Public cCity
Public cState
Public cCountry
Public cMail
Public cVat
Public cWebsite
Public cUrl
Public cLogo
Public cLogoPath
Public cPhone
Public cFax
'User properties
Public uName
Public uMail
Public uPhone
Public uCell
Public uFax
Public uTitle
Public uDepartment
Public uDisclaimer
Private Sub Class_Initialize()
me.sName = "The name of my signature"
me.sVersion = CDate("1/10/2012")
me.sTemplate = "Default.vbs"
me.cName = "MY COMPANY NAME"
me.cStreet = "Street"
me.cBox = "123"
me.cPostal = "ZIP"
me.cCity = "CITY"
me.cMail = "info@company.com"
me.cVat = "VAT NUMBER"
me.cWebsite = "www.company.com"
me.cUrl = "http://www.company.com"
me.cPhone = "+32 3 456 780"
me.cFax = "+32 3 456 789"
me.uName = "John Doe"
me.uPhone = "+32 3 456 780"
me.uFax = "+32 3 456 780"
End Sub
Public Property Get sPath()
sPath = oShell.ExpandEnvironmentStrings("%AppData%") + "\Microsoft\" & oShell.RegRead("HKCU\Software\Microsoft\Office\" & outlook_Version & "\Common\General\Signatures") & "\" & me.sName & ".htm"
End Property
End Class
Function SortArray(arrShort)
Dim i, j, temp
For i = UBound(arrShort) - 1 To 0 Step -1
For j= 0 To i
If arrShort(j)>arrShort(j+1) Then
temp=arrShort(j+1)
arrShort(j+1)=arrShort(j)
arrShort(j)=temp
End If
Next
Next
SortArray = arrShort
End Function
Function GetMembership(sChild, dMembership)
'Get AD info on the given Child
Set oChild = GetObject("LDAP://" & sChild)
If TypeName(oChild) = "Object" Then
'Add the Child's canonical name to the array IF it's a group
If TypeName(dMembership) = "Dictionary" Then
dMembership.Add oChild.distinguishedName, oChild.CN
Else
Set dMembership = CreateObject("Scripting.Dictionary")
End If
'If the Child has any parents (=groups), run the same loop for these parents.
If TypeName(oChild.memberOf) = "Variant()" Then
oParents = oChild.GetEx("memberOf")
For Each sParent in oParents
If Not dMembership.Exists(sParent) Then
Set dMembership = GetMembership(sParent, dMembership)
End If
Next
End If
End If
Set GetMembership = dMembership
End Function
在签名“指南”下方。这些脚本必须与 AD 中创建的组具有相同的名称才能工作。当用户是 AD 组 Signature-Marketing 的成员时,它将运行 \\MyDomain.local\NETLOGON\Outlook\Signatures\Signature-Marketing.vbs
'\\MyDomain.local\NETLOGON\Outlook\Signatures\MyGroupName.vbs
'Set specific default values
Signature.sVersion = CDate("3/12/2012 15:35")
Signature.sName = "The name of my signature"
Signature.sCompanyNew = "MY COMPANY NAME"
Signature.sCompanyReply = "MY COMPANY NAME"
Signature.cName = "MY COMPANY NAME"
Signature.cStreet = "Street"
Signature.cBox = "123"
Signature.cPostal = "ZIP"
Signature.cCity = "City"
Signature.cMail = "info@company.com"
Signature.cVat = "VAT NUMBER"
Signature.cWebsite = "www.company.com"
Signature.cUrl = "http://www.company.com"
Signature.cLogo = "\\MyDomain.local\NETLOGON\Outlook\IMG\MyCompanyLogo.png"
Signature.cPhone = "+32 3 456 780"
Signature.cFax = "+32 3 456 789"
Signature.uName = "John Doe"
Signature.uPhone = "+32 3 456 780"
Signature.uFax = "+32 3 456 789"
位于默认模板下方。该脚本在 Outlook.vbs 中进行评估
'\\MyDomain.local\NETLOGON\Outlook\Templates\Default.vbs
oSelection.Font.Name = "Calibri"
oSelection.Font.Size = 11
oSelection.TypeText Signature.uName
If Not Signature.uTitle = "" Then
oSelection.TypeText Chr(11)
oSelection.TypeText Signature.uTitle
End If
If Not Signature.uDisclaimer = "" Then oSelection.TypeText " (*)"
' ### Add company table & info
oSelection.TypeParagraph()
Set tbl = oDoc.Tables.Add(oSelection.Range, 1, 2)
Set oTable = oDoc.Tables(1)
tWidth = oTable.Cell(1, 1).width + oTable.Cell(1, 2).width
' Add company logo to cell 1
Set oCell = oTable.Cell(1, 1)
Set oCellRange = oCell.Range
oCell.Select
Set oLogo = oSelection.InlineShapes.AddPicture(Signature.cLogo)
oLogo.LockAspectRatio = true
oLogo.height = oWord.PixelsToPoints(50)
oCell.width = oLogo.width
' Add company info to cell 2
If Signature.cVat = "" Then
arrAddressInfo = Array(Signature.cName, Signature.cStreet & " " & Signature.cBox, Signature.cPostal & " " & Signature.cCity)
Else
arrAddressInfo = Array(Signature.cName, Signature.cStreet & " " & Signature.cBox, Signature.cPostal & " " & Signature.cCity, Signature.cVat)
End If
strAddressInfo = Join(arrAddressInfo, " | ")
Set oCell = oTable.Cell(1, 2)
Set oCellRange = oCell.Range
oCell.Select
oCell.width = tWidth - oLogo.width
oSelection.Font.Size = 10
oSelection.TypeText strAddressInfo
' Add phone number information
arrUserInfo = Array()
If Not Signature.uPhone = "" Then
ReDim Preserve arrUserInfo(UBound(arrUserInfo) + 1)
arrUserInfo(UBound(arrUserInfo)) = "T " & Signature.uPhone
End If
If Not Signature.uCell = "" Then
ReDim Preserve arrUserInfo(UBound(arrUserInfo) + 1)
arrUserInfo(UBound(arrUserInfo)) = "G " & Signature.uCell
End If
If Not Signature.uFax = "" Then
ReDim Preserve arrUserInfo(UBound(arrUserInfo) + 1)
arrUserInfo(UBound(arrUserInfo)) = "F " & Signature.uFax
End If
strUserInfo = Join(arrUserInfo, " | ")
If Not strUserInfo = "" Then
oSelection.TypeText Chr(11)
oSelection.TypeText strUserInfo
End If
oSelection.TypeText Chr(11)
' Add user mail address to cell 2
Set oLink = oSelection.Hyperlinks.Add(oSelection.Range, "mailto:" & Signature.uMail, , , Signature.uMail)
oLink.Range.Font.Color = oSelection.Font.Color
oLink.Range.Font.Size = 10
' Add company weblink to cell 2
oSelection.TypeText " | "
Set oLink = oSelection.Hyperlinks.Add(oSelection.Range, Signature.cUrl, , , Signature.cWebsite)
oLink.Range.Font.Color = oSelection.Font.Color
oLink.Range.Font.Size = 10
If Not Signature.uDisclaimer = "" Then oSelection.TypeText " | (*) " & Signature.uDisclaimer
tbl.Rows(1).Cells.VerticalAlignment = 1
oTable.AutoFitBehavior(1)
\\MyDomain.local\NETLOGON\Outlook\PRF\Outlook_Cached.PRF
\\MyDomain.local\NETLOGON\Outlook\PRF\Outlook_NotCached.PRF
创建您自己的 PRF 文件(引自 Microsoft TechNet):
使用 Office 自定义工具创建 PRF 文件
关于vbscript - 使用多个签名由 GPO 自动生成 Outlook 签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15790981/
以下 Outlook 的命令适用于 Outlook 2010: outlook.exe /c ipm.note /m "&subject=abc" /a "c:\attach.txt" 但它不适用于
我有 2 个电子邮件帐户,一个是 Gmail,另一个是 Outlook。我想在邮件到达时自动将进入 Outlook 的邮件接收到 Gmail。我该怎么做?Outlook 是否存在任何可能阻碍此操作的安
Outlook 加载项如何在邮件上设置 MAPI 属性(例如正文内容),但仅将其保存在本地缓存中(而不发送回 Exchange 服务器)?我见过使用一些加密插件来完成此操作。 我愿意使用几乎任何可以实
有什么方法可以在 Outlook 的模板主题或正文中插入今天的日期吗?这样,每当我打开保存的模板时,今天的日期就会自动显示在主题和正文中。 有什么内置功能吗?像 Date() 这样的东西? 最佳答案
我有一个时事通讯系统,可以跟踪阅读它的人。尽管此功能仅在允许下载图像的情况下才有效。但这不是我现在的问题。 我的问题是,当我在 Outlook (2010) 中打开新闻稿并授予下载图像的权限时,我的系
我需要从 Outlook msg 文件中读取内容。目前我正在使用来自 CodeProject.com 的类(class)项目来实现这一点,因为在服务器上部署 VSTO 和 Outlook 不是一种选择
我正在开发可与共享邮箱一起使用的 Outlook 加载项。目前,office 插件在委托(delegate)场景中不可用,但 MS 已经发布了支持这些场景的预览版本。https://learn.mic
我正在开发可与共享邮箱一起使用的 Outlook 加载项。目前,office 插件在委托(delegate)场景中不可用,但 MS 已经发布了支持这些场景的预览版本。https://learn.mic
我开发了一个运行良好的 Outlook Web 插件。它是一个任务 Pane ,可在约会的组合模式下使用,它收集事件数据、添加一些数据并将其发送到某个地方的 API。 我现在想做的是将经过身份验证的用
在 Outlook for Mac 中,office.js Outlook 加载项在我假设是 Safari Web 控件的任务 Pane 中运行。我无法确定您如何从任务 Pane 中运行的加载项中清除
Marshal.GetActiveObject("Outlook.Application") 在 Outlook 启动并继续运行时抛出 操作不可用(HRESULT 异常:0x800401E3 (MK_
我有一个 VSTO Outlook 2007 加载项。我必须检查 Outlook 是否与交换服务器脱机/联机。我正在使用如下代码: NameSpace ns = Application.GetNam
我正在尝试在图像上方添加文本,如下所示。它适用于除 Outlook 2010、Outlook 2007、Outlook 2013 之外的所有电子邮件客户端。所有这三个客户端都忽略了填充。我到处都试过了
有没有办法处理 Outlook 邮件项中收件人的悬停事件?我想在悬停时显示一个弹出窗口,其中包含有关收件人的一些信息,并想知道是否可以通过 Outlook 加载项实现。 最佳答案 因为 Inspect
我正在尝试在 Outlook 2007 中创建、更新和删除事件(但最好它适用于所有版本)。创建和删除事件工作正常。我关注了 several threads但由于某种原因更新操作失败。 当我双击 ICS
我在 ms Outlook 中有 2 个帐户('user1@test.com' - 默认配置文件,'user2@test.com'),我正在尝试使用非默认帐户通过 python 发送消息。这是我的代码
我有一个我最近继承的Outlook 2007加载项,目前在生产中存在一个问题,有些用户正在周期性地,似乎是随机地禁用其加载项。外接程序中没有日志,并且在外接程序代码中的每个方法/事件调用周围都存在tr
是否可以为 创建 HTML 电子邮件签名? 2003年展望或以上不引用外部图像? 也就是说,使用那些特殊的“cid”引用,但将图像本身嵌入到签名中,而不是嵌入到文件系统或网络中。 这适用于根据用户的各
似乎没有太多信息或任何好的代码示例用于以编程方式设置 Outlook 2007 MailItem 的类别。 MSDN has a limited page ,并提到使用 VB 的 拆分 功能,或多或少
Outlook 2007 在 Outlook 中撰写新邮件时,可以创建指向其他邮件的链接吗? Whww 我正在撰写一封新邮件,我想创建一个指向已发送项目的链接,单击此链接应该会打开邮件。 这能做到吗?
我是一名优秀的程序员,十分优秀!