Advertisement
Guest User

OutlookSignatureDeploy.vbs

a guest
May 3rd, 2018
243
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. 'Declarations
  14. strName = objUser.FullName
  15. strTitle = objUser.Title
  16. strCred = objUser.info
  17. strStreet = objUser.StreetAddress
  18. strState = objUser.st
  19. strLocation = objUser.l
  20. strPostCode = objUser.PostalCode
  21. strPhone = objUser.TelephoneNumber
  22. strDirect = objUser.ipPhone
  23. strMobile = objUser.Mobile
  24. strEmail = objUser.mail
  25. strWebsite = objUser.wWWHomePage
  26. strOffice = objUser.physicalDeliveryOfficeName
  27.  
  28. 'Creates word application for formatting
  29. Set objWord = CreateObject("Word.Application")
  30. Set objDoc = objWord.Documents.Add()
  31. Set objSelection = objWord.Selection
  32. Set objEmailOptions = objWord.EmailOptions
  33. Set objSignatureObject = objEmailOptions.EmailSignature
  34. Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
  35.  
  36. 'Signature Font
  37. objSelection.Font.Name = "Verdana"
  38. objSelection.Font.Size = 10 'Carries over unless specified again elsewhere
  39.  
  40. 'Salutation
  41. objSelection.font.color = rgb(0,0,0)
  42. objSelection.TypeText "Regards,"
  43. objSelection.TypeText Chr(11)
  44.  
  45. 'Line break
  46. objSelection.TypeParagraph()
  47.  
  48. 'Username line
  49. objSelection.Font.Size = 12
  50. objSelection.Font.Bold = true
  51. if (strCred) Then objSelection.TypeText strName & ", " & strCred Else objSelection.TypeText strName
  52. objSelection.Font.Bold = false
  53.  
  54. 'Job title line
  55. objSelection.Font.Size = 10
  56. objSelection.TypeParagraph()
  57. objSelection.ParagraphFormat.LineSpacing = 16
  58. objSelection.TypeText strTitle
  59. objSelection.TypeText Chr(11)
  60.  
  61. 'Location line
  62. objSelection.Font.Bold = true
  63. objSelection.font.color = rgb(210,73,42)
  64. objSelection.TypeText strOffice & " Office " & "| FLOTH Sustainable Building Consultants"
  65. objSelection.Font.Bold = False
  66. objSelection.TypeText Chr(11)
  67.  
  68. 'Address line
  69. objSelection.Font.Size = 9
  70. objSelection.font.color = rgb(0,0,0)
  71. objSelection.TypeText strStreet & ", " & strLocation & ", " & strState & ", " & strPostCode
  72. objSelection.TypeText Chr(11)
  73.  
  74. 'Contact line
  75. objSelection.Font.Size = 8
  76. objSelection.font.color = rgb(0,0,0)
  77. objSelection.TypeText "P: " & strPhone & " | D: " & strDirect & " | E: " & strEmail & " | W: " & strWebsite
  78. objSelection.TypeText Chr(11)
  79.  
  80. ' If statement to hyperlink website
  81. ' Don't really need this as most email clients auto format the email and website to hyperlinks
  82. ' if strWebsite then
  83. ' Set objLink = objSelection.Hyperlinks.Add(objselection.Range,strWebsite)
  84.     ' objLink.Range.Font.Name = "Verdana"
  85.     ' objLink.Range.Font.Size = 8
  86.     ' objLink.Range.Font.Bold = false
  87. ' end if
  88. ' objSelection.TypeText Chr(11)
  89.  
  90. 'Image description or disclaimer
  91. objSelection.Font.Size = 9
  92. objSelection.Font.Bold = true
  93. objSelection.font.color = rgb(0,187,0)
  94. objSelection.TypeText "Winner of the 2017 Brisbane Lord Mayors Business Awards for Sustainability in Business, awarded to Floth for 69 Robertson Street, Fortitude Valley."
  95. objSelection.Font.Bold = false
  96. objSelection.TypeText Chr(11)
  97.  
  98. 'New signature image adding - Place script and file in NETLOGON and adjust image file path
  99. Set shp = objSelection.InlineShapes.AddPicture("\\flsvr03\Software\_New Machine Install\SIGTEST\LMBA_Landscape_DarkGreen_668x126.jpg")
  100. shp.LockAspectRatio = msoFalse
  101. shp.Width = 456
  102. shp.Height = 86
  103.  
  104. 'Can make an if statement for if there is a badge signature instead of a banner.
  105.  
  106.  
  107. 'Experimental code for multuple departments with different signature images
  108. ' If (objUser.Department = "COMPANY NAME.") Then
  109.             ' objSelection.InlineShapes.AddPicture("\LMBA_Landscape_DarkGreen_668x126.jpg")
  110.  
  111.  
  112. ' ElseIf (objUser.Department = "COMPANY NAME") Then
  113.        ' objSelection.InlineShapes.AddPicture("\LMBA_Landscape_DarkGreen_668x126.jpg")
  114.  
  115. ' Else
  116.        ' objSelection.InlineShapes.AddPicture("\LMBA_Landscape_DarkGreen_668x126.jpg")
  117.  
  118. ' End If
  119.  
  120. Set objSelection = objDoc.Range()
  121.  
  122. objSignatureEntries.Add "Email Signature", objSelection
  123. objSignatureObject.NewMessageSignature = "Email Signature"
  124. objSignatureObject.ReplyMessageSignature = "Email Signature"
  125.  
  126. objDoc.Saved = True
  127. objWord.Quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement