Advertisement
Guest User

OutlookSignatureDeploy.vbs

a guest
May 3rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. On Error Resume Next
  2.  
  3. 'References
  4. 'All objuser.XXXX and there counterparts in AD
  5. 'https://ss64.com/vb/syntax-userinfo.html
  6.  
  7. Set objSysInfo = CreateObject("ADSystemInfo")
  8. Set WshShell = CreateObject("WScript.Shell")
  9.  
  10. strUser = objSysInfo.UserName
  11. Set objUser = GetObject("LDAP://" & strUser)
  12.  
  13. strName = objUser.FullName
  14. strTitle = objUser.Title
  15. strCred = objUser.info
  16. strStreet = objUser.StreetAddress
  17. strState = objUser.st
  18. strLocation = objUser.l
  19. strPostCode = objUser.PostalCode
  20. strPhone = objUser.TelephoneNumber
  21. strDirect = objUser.ipPhone
  22. strMobile = objUser.Mobile
  23. strEmail = objUser.mail
  24. strWebsite = objUser.wWWHomePage
  25. strOffice = objUser.physicalDeliveryOfficeName
  26.  
  27. 'Creates word application with formatting - .htm
  28. Set objWord = CreateObject("Word.Application")
  29.  
  30. Set objDoc = objWord.Documents.Add()
  31. Set objSelection = objWord.Selection
  32.  
  33. Set objEmailOptions = objWord.EmailOptions
  34. Set objSignatureObject = objEmailOptions.EmailSignature
  35.  
  36. Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
  37.  
  38. 'Signature Font
  39. objSelection.Font.Name = "Verdana"
  40. objSelection.Font.Size = 11 'Carries over unless specified again elsewhere
  41.  
  42. 'Regards
  43. objSelection.font.color = rgb(0,0,0)
  44. objSelection.TypeText "Regards,"
  45. objSelection.TypeText Chr(11)
  46.  
  47. 'Line break - Don't know a better way
  48. objSelection.TypeText space(1)
  49. objSelection.TypeText Chr(11)
  50.  
  51. 'Username line
  52. objSelection.Font.Size = 13
  53. objSelection.Font.Bold = true
  54. if (strCred) Then objSelection.TypeText strName & ", " & strCred Else objSelection.TypeText strName
  55. objSelection.Font.Bold = false
  56.  
  57. 'Job title line
  58. objSelection.Font.Size = 11
  59. objSelection.TypeParagraph()
  60. objSelection.ParagraphFormat.LineSpacing = 16
  61. objSelection.TypeText strTitle
  62. objSelection.TypeText Chr(11)
  63.  
  64. 'Location line
  65. objSelection.Font.Bold = true
  66. objSelection.font.color = rgb(210,73,42)
  67. objSelection.TypeText strOffice & " Office " & "| FLOTH Sustainable Building Consultants"
  68. objSelection.Font.Bold = False
  69. objSelection.TypeText Chr(11)
  70.  
  71. 'Address line
  72. objSelection.font.color = rgb(0,0,0)
  73. objSelection.TypeText strStreet & ", " & strLocation & ", " & strState & ", " & strPostCode
  74. objSelection.TypeText Chr(11)
  75.  
  76. 'Contact line
  77. objSelection.font.color = rgb(0,0,0)
  78. objSelection.TypeText "P: " & strPhone & " | D: " & strDirect & " | M: " & strMobile & " | E: " & strEmail & " | W: " & strWebsite
  79. objSelection.TypeText Chr(11)
  80.  
  81. 'Image description or disclaimer
  82. objSelection.Font.Bold = true
  83. objSelection.font.color = rgb(0,187,0)
  84. objSelection.TypeText "Winner of the 2017 Brisbane Lord Mayors Business Awards for Sustainability in Business, awarded to Floth for 69 Robertson Street, Fortitude Valley."
  85. objSelection.Font.Bold = false
  86. objSelection.TypeText Chr(11)
  87.  
  88. 'New signature image adding - Point towards image file NETLOGON so everyone has access
  89. Set shp = objSelection.InlineShapes.AddPicture("S:\_New Machine Install\SIGTEST\LMBA_Landscape_DarkGreen_668x126.jpg")
  90. shp.LockAspectRatio = msoFalse
  91. shp.Width = 668
  92. shp.Height = 126
  93.  
  94. 'Experimental code for multuple departments with different signature images
  95. ' If (objUser.Department = "COMPANY NAME.") Then
  96.             ' objSelection.InlineShapes.AddPicture("\LMBA_Landscape_DarkGreen_668x126.jpg")
  97.  
  98.  
  99. ' ElseIf (objUser.Department = "COMPANY NAME") Then
  100.        ' objSelection.InlineShapes.AddPicture("\LMBA_Landscape_DarkGreen_668x126.jpg")
  101.  
  102. ' Else
  103.        ' objSelection.InlineShapes.AddPicture("\LMBA_Landscape_DarkGreen_668x126.jpg")
  104.  
  105. ' End If
  106.  
  107.  
  108. Set objSelection = objDoc.Range()
  109.  
  110. objSignatureEntries.Add "Email Signature", objSelection
  111. objSignatureObject.NewMessageSignature = "Email Signature"
  112. objSignatureObject.ReplyMessageSignature = "Email Signature"
  113.  
  114. objDoc.Saved = True
  115. objWord.Quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement