Guest User

AD auto signature

a guest
Mar 9th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.51 KB | None | 0 0
  1. '*****************************************
  2. ' Script to set signature using Active
  3. ' Directory fields.
  4. ' Only works when connected to Active
  5. ' Directory
  6. '
  7. ' Written By: Steve Chambers
  8. ' Date: 13/09/07
  9. '
  10. '*****************************************
  11.  
  12.  
  13. On Error Resume Next
  14.  
  15. Set objSysInfo = CreateObject("ADSystemInfo")
  16.  
  17. strUser = objSysInfo.UserName
  18. Set objUser = GetObject("LDAP://" & strUser)
  19.  
  20. strName = objUser.FullName
  21. strTitle = objUser.Title
  22. strDepartment = objUser.Department
  23. strCompany = objUser.Company
  24. strPhone = objUser.telephoneNumber
  25. strFax = objUser.Faxnumber
  26. strstreetAddress = objUser.streetAddress
  27. strl = objUser.l
  28. strst = objUser.st
  29. strpostalCode = objUser.postalCode
  30. strmail = objUser.mail
  31. strwWWHomePage = objUser.wWWHomePage
  32.  
  33.  
  34. Set objWord = CreateObject("Word.Application")
  35.  
  36. Set objDoc = objWord.Documents.Add()
  37. Set objSelection = objWord.Selection
  38.  
  39. Set objEmailOptions = objWord.EmailOptions
  40. Set objSignatureObject = objEmailOptions.EmailSignature
  41.  
  42. Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
  43.  
  44. objSelection.Font.Name = "Arial"
  45. objSelection.Font.Size = "16"
  46.  
  47. objSelection.TypeText strName
  48. objSelection.TypeParagraph()
  49.  
  50. objSelection.Font.Size = "12"
  51.  
  52. objSelection.TypeText strTitle
  53. objSelection.TypeParagraph()
  54. objSelection.TypeParagraph()
  55. objSelection.TypeText strCompany
  56. objSelection.TypeParagraph()
  57. objSelection.TypeText strstreetAddress
  58. objSelection.TypeParagraph()
  59. objSelection.TypeText strl
  60. objSelection.TypeParagraph()
  61. objSelection.TypeText strst
  62. objSelection.TypeText ", "
  63. objSelection.TypeText strpostalCode
  64. objSelection.TypeParagraph()
  65. objSelection.TypeParagraph()
  66.  
  67.  
  68. objSelection.TypeText "T: "
  69. objSelection.TypeText strPhone
  70. objSelection.TypeParagraph()
  71. objSelection.TypeText "F: "
  72. objSelection.TypeText strFax
  73. objSelection.TypeParagraph()
  74. objSelection.TypeText "E: "
  75. objSelection.TypeText strmail
  76. objSelection.TypeParagraph()
  77. objSelection.TypeText "I: "
  78. objSelection.TypeText strwWWHomePage
  79. objSelection.TypeParagraph()
  80. objSelection.TypeParagraph()
  81.  
  82. Set objShape = objSelection.InlineShapes.AddPicture("\\sjsj-fs01\sjsj_data$\Intranet\Achtergrond_e-mailhandtekening.jpg")
  83. objSelection.TypeParagraph()
  84. objSelection.TypeParagraph()
  85.  
  86. objSelection.Font.Size = "10"
  87.  
  88. objSelection.TypeText " "
  89.  
  90. Set objSelection = objDoc.Range()
  91.  
  92. objSignatureEntries.Add "AD Signature", objSelection
  93. objSignatureObject.NewMessageSignature = "AD Signature"
  94. objSignatureObject.ReplyMessageSignature = "AD Signature"
  95.  
  96. objDoc.Saved = True
  97. objWord.Quit
Advertisement
Add Comment
Please, Sign In to add comment