' ######## New Signature ########
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set WshShell = CreateObject("WScript.Shell")
strUser = objSysInfo.UserName
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & strUser)
Set objGroup1 = GetObject("LDAP://cn=All RCDAs,ou=User Accounts,dc=our domain,dc=local")
Set objGroup2 = GetObject("LDAP://cn=All National Office,ou=User Accounts,dc=<our domain>,dc=local")
'map Active Directory objUser to str names'
strName = objUser.FullName
strNotes = objuser.Info
strTitle = objUser.Title
strPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strEmail = objUser.mail
'set pointers for image insertion with linked URL'
sPicFile = "\\ARTIC\Office2007ProPlus\Scripts\edin4.png"
sLinkFile = "http://www.our domain.org/blah.html"
'Use Word (required) to create the format'
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Style = "No Spacing"
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
'If you get problems with line spacing, use vbNewline instead of Chr(11)'
'Select what is displayed in the Signature based upon the str to ObjUser mappings above'
objSelection.Font.Bold = True
'objSelection.Font.Name = "Arial"
objSelection.Font.Size = 11
'if (strCred) Then objSelection.TypeText strName & ", " & strCred Else objSelection.TypeText strName & Chr(32) & strNotes & Chr(11)
'if (strName) Then objSelection.TypeText strName & ", " & strNotes & Chr(11)
if (strName) Then objSelection.TypeText strName & strNotes & Chr(11)
objSelection.Font.Bold = False
objSelection.TypeText strTitle & Chr(11)
objSelection.TypeText "Our company name" & Chr(11)
' If member of AD group All National Office (as defined above) then plant National Office address
if (objGroup2.IsMember(objUser.AdsPath) = True) Then
objSelection.TypeText "PO Box address here" & Chr(11)
else
'display nothing
end if
' If Telephone number is populated in AD then set and plant Internationally defined number (lines 1 and 2 are only required for the International Signature)
'strPhone = right(strPhone,len(strPhone)-1) 'strips off left most digit
'strPhone = "+44 " & strPhone
if (objUser.TelephoneNumber) Then objSelection.TypeText "DD: " & strPhone & Chr(11)
' if member of AD group RCDS's (as defined above) do nothing, otherwise plant Mobile number
'if (objGroup1.IsMember(objUser.AdsPath) = True) Then
' CHR(11)
'else
' if (strMobile) Then objSelection.TypeText "Mobile: " & strMobile & Chr(11)
'end if
if (strMobile) Then objSelection.TypeText "Mobile: " & strMobile & Chr(11)
objSelection.Hyperlinks.Add objSelection.Range, "http://www.our domain",, "Our company Homepage", "www.our domain"
With objDoc.Styles("Hyperlink").Font
.Name = "Arial"
.Bold = False
'.Underline = wdUnderlineNone
.Color = RGB(227,114,34)
End With
objSelection.TypeParagraph()
objSelection.TypeParagraph()
Set objShape1 = objSelection.InlineShapes.AddPicture(sPicFile, True)
objDoc.Hyperlinks.Add objShape1.Range, sLinkFile
'add the entire range of what you want displayed and set the global font'
Set objSelection = objDoc.Range()
objSelection.Font.Name = "Arial"
'Add a siganture entry, name it and assign to new message'
objSignatureEntries.Add "Full Signature", objSelection
objSignatureObject.NewMessageSignature = "Full Signature"
'Save the content and exit'
objDoc.Saved = True
objWord.Quit
----------------------------------------
Other code I've been working on.
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
Set UserObj = GetObject("LDAP://" & objADSysInfo.UserName)
' work in progress check signature existence and exit if exist or not changed
strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%")
SigFolder = StrAppData & "\Microsoft\Signatures\"
strQuteChr = chr(34)
SigFile = SigFolder & UserObj.sAMAccountName & ".htm"
'check existence of signature folder, if not exist create it
if not FileSysObj.FolderExists(SigFolder) then
FileSysObj.CreateFolder(SigFolder)
end if
if FileSysObj.FileExists(SigFile) then
'get amended date of file, then compare it to the changed date of the user
Set objFile = FileSysObj.GetFile(SigFile)
datSigAlt = objFile.DateLastModified
intTimeDiff = DateDiff("n", datSigAlt, UserObj.whenChanged)
'if the difference is less than 0 then we do not need to do anything as the sig file is uptodate
if intTimeDiff < 0 then wscript.Quit
end if
'end work in progress