#200231 - 2010-10-11 11:31 AM
vCard attach to a Outlook Signature
|
Michael_Schou
Just in Town
Registered: 2010-10-11
Posts: 3
Loc: Denmark
|
We have a customer who has asked for the possibility to add a vCard to all of the users in the Org using a script.
As of now the Outlook signature is defined using AD commands so all the info are pulled from the users Active Directory.
I have attached the script we currently are using.
So any of you guys now how attach a vCard to all the Outlook signatures ?
Attachments
SignatureScript.txt (603 downloads) Description:
|
|
Top
|
|
|
|
#200236 - 2010-10-11 08:54 PM
Re: vCard attach to a Outlook Signature
[Re: Michael_Schou]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Not what you're asking, but I was bored so I translated your script to KiX. At least others can help better with this code: Welcome to the board btw 
; Create Signature from AD Data
Function GetUserDN($UN, $DN)
$ObjTrans = CreateObject("NameTranslate")
$objTrans.init(1, $DN)
$objTrans.set(3, $DN + "\" + $UN)
$strUserDN = $objTrans.Get(1)
$GetUserDN = $strUserDN
EndFunction
$objLDAPUser = GetObject("LDAP://" + GetUserDN(@USERID,@LDOMAIN))
;Creating som files
Dim $objFSO, $objWsh, $appDataPath, $pathToCopyTo, $plainTextFile, $plainTextFilePath, $richTextFile, $richTextFilePath, $htmlFile, $htmlFilePath
$objWsh = CreateObject("WScript.Shell")
$appDataPath = $objWsh.ExpandEnvironmentStrings("%APPDATA%")
$pathToCopyTo = $appDataPath + "\Microsoft\Signaturer\"
;? $pathToCopyTo
;Check if the directory exists
;If not then plz create it
$objFSO = CreateObject("Scripting.FileSystemObject")
If NOT $objFSO.FolderExists($pathToCopyTo)
$objFolder = $objFSO.CreateFolder($pathToCopyTo)
EndIf
;Copy logo to signature folder
$FileToCopy = $objFSO.GetFile("\\domain.local\netlogon\signatur\image001.png")
$FileToCopy.Copy($pathToCopyTo)
$FileToCopy = $objFSO.GetFile("\\domain.local\netlogon\signatur\image002.png")
$FileToCopy.Copy($pathToCopyTo)
$FileToCopy = $objFSO.GetFile("\\domain.local\netlogon\signatur\image003.png")
$FileToCopy.Copy($pathToCopyTo)
$FileToCopy = $objFSO.GetFile("\\domain.local\netlogon\signatur\Signature.rtf")
$FileToCopy.Copy($pathToCopyTo)
;Creating TXT signature
$txtFilePath = $pathToCopyTo + "Signature.txt"
$txtFile = $objFSO.CreateTextFile($txtFilePath, 1)
$txtfile.WriteLine("")
$txtfile.WriteLine("Venlig hilsen")
$txtfile.WriteLine("")
$txtfile.WriteLine($objLDAPUser.DisplayName)
$txtfile.WriteLine($objLDAPUser.title)
$txtfile.WriteLine("")
$txtfile.WriteLine($objLDAPUser.st)
$txtfile.WriteLine($objLDAPUser.streetAddress + " | " + $objLDAPUser.PostalCode + " " + $objLDAPUser.l)
If NOT $objLDAPUser.TelephoneNumber = ""
$txtfile.WriteLine("Telefon: " + $objLDAPUser.otherTelephone + " | Direkte: " + $objLDAPUser.TelephoneNumber)
Else
$txtfile.WriteLine("Telefon: " + $objLDAPUser.otherTelephone)
EndIf
If NOT $objLDAPUser.mobile = ""
$txtfile.WriteLine("Telefax: " + $objLDAPUser.facsimileTelephoneNumber + " | Mobil: " + $objLDAPUser.mobile)
Else
$txtfile.WriteLine("Telefax: " + $objLDAPUser.facsimileTelephoneNumber)
EndIf
$txtfile.WriteLine("")
$txtfile.WriteLine($objLDAPUser.mail + " | www.domain.dk")
;Creating HTML signature
$htmlFilePath = $pathToCopyTo + "Signature.htm"
$htmlFile = $objFSO.CreateTextFile($htmlFilePath, 1)
$htmlfile.WriteLine("<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">")
$htmlfile.WriteLine("<html>")
$htmlfile.WriteLine(" <body style=""font-family:Tahoma;font-size:10pt;color:#000000;"">")
$htmlfile.WriteLine(" <div style=""font-family:Tahoma;font-size:10pt"">")
$htmlfile.WriteLine(" <br/>")
$htmlfile.WriteLine(" Venlig hilsen<br/>")
$htmlfile.WriteLine(" <br/>")
$htmlfile.WriteLine(" <b>" + $objLDAPUser.DisplayName + "</b><br/>")
$htmlfile.WriteLine(" " + $objLDAPUser.title + "<br/>")
$htmlfile.WriteLine(" <br/>")
$htmlfile.WriteLine(" <img src=""image001.png"" width=""535"" height=""65"" alt=""""/><br/><br/>")
$htmlfile.WriteLine(" " + $objLDAPUser.st + "<br/>")
$htmlfile.WriteLine(" " + $objLDAPUser.streetAddress + " | " + $objLDAPUser.PostalCode + " " + $objLDAPUser.l + "<br/>")
$htmlfile.WriteLine(" </div>")
$htmlfile.WriteLine(" <table width=""535"" border=""0"" cellspacing=""0"" cellpadding=""0"" style=""font-family:Tahoma;font-size:10pt;color:#000000;"">")
$htmlfile.WriteLine(" <tr>")
$htmlfile.WriteLine(" <td>")
$htmlfile.WriteLine(" <table border=""0"" cellspacing=""0"" cellpadding=""0"" style=""font-family:Tahoma;font-size:10pt;color:#000000;"">")
$htmlfile.WriteLine(" <tr>")
$htmlfile.WriteLine(" <td>Telefon: </td>")
$htmlfile.WriteLine(" <td>" + $objLDAPUser.otherTelephone + "</td>")
; Direct Phone Number
If NOT $objLDAPUser.TelephoneNumber = ""
$htmlfile.WriteLine(" <td> |</td>")
$htmlfile.WriteLine(" <td> Direkte: </td>")
$htmlfile.WriteLine(" <td>" + $objLDAPUser.TelephoneNumber + "</td>")
Else
$htmlfile.WriteLine(" <td> </td>")
$htmlfile.WriteLine(" <td> </td>")
$htmlfile.WriteLine(" <td> </td>")
EndIf
$htmlfile.WriteLine(" </tr>")
$htmlfile.WriteLine(" <tr>")
$htmlfile.WriteLine(" <td>Telefax: </td>")
$htmlfile.WriteLine(" <td>" + $objLDAPUser.facsimileTelephoneNumber + "</td>")
If NOT $objLDAPUser.mobile = ""
$htmlfile.WriteLine(" <td> |</td>")
$htmlfile.WriteLine(" <td> Mobil: </td>")
$htmlfile.WriteLine(" <td>" + $objLDAPUser.mobile + "</td>")
Else
$htmlfile.WriteLine(" <td> </td>")
$htmlfile.WriteLine(" <td> </td>")
$htmlfile.WriteLine(" <td> </td>")
EndIf
$htmlfile.WriteLine(" </tr>")
$htmlfile.WriteLine(" </table>")
$htmlfile.WriteLine(" <br/>")
$htmlfile.WriteLine(" <a href=""mailto:" + $objLDAPUser.mail + """>" + $objLDAPUser.mail + "</a>")
$htmlfile.WriteLine(" | ")
$htmlfile.WriteLine(" <a href=""http://www.domain.dk"">www.domain.dk</a><br/>")
$htmlfile.WriteLine(" </td>")
$htmlfile.WriteLine(" <td style=""text-align:right;vertical-align:bottom"">")
$htmlfile.WriteLine(" <img src=""image002.png"" width=""124"" height=""38"" alt="""">")
$htmlfile.WriteLine(" </td>")
$htmlfile.WriteLine(" </tr>")
$htmlfile.WriteLine(" </table>")
$htmlfile.WriteLine(" <img src=""image003.png"" width=""535"" height=""17"" alt=""""/><br/>")
$htmlfile.WriteLine(" <div style=""font-size:7pt"">")
$htmlfile.WriteLine(" <table style=""WIDTH: 534px; BORDER-COLLAPSE: collapse; HEIGHT: 26px"" width=534 border=0>")
$htmlfile.WriteLine(" <tbody>")
$htmlfile.WriteLine(" <tr>")
$htmlfile.WriteLine(" <td width=377>")
$htmlfile.WriteLine(" <a href=""http://www.domain.dk/Default.aspx?ID=161""><font face=Tahoma size=1>Disclaimer</font></a><font face=Tahoma size=1> | </font>")
$htmlfile.WriteLine(" <a href=""http://www.domain.dk/Default.aspx?ID=162""><font size=1><font face=Tahoma>Disclaimer</font></font></a></td>")
$htmlfile.WriteLine(" <td align=right><font face=Tahoma color=#810081 size=1>")
$htmlfile.WriteLine(" <a href=""http://www.domain.dk/Default.aspx?ID=22"">Newsletter</a></font>")
$htmlfile.WriteLine(" </td>")
$htmlfile.WriteLine(" </tr>")
$htmlfile.WriteLine(" </tbody>")
$htmlfile.WriteLine(" </table>")
$htmlfile.WriteLine(" </div>")
$htmlfile.WriteLine(" <br/>")
$htmlfile.WriteLine(" </body>")
$htmlfile.WriteLine("</html>")
$objWord = CreateObject("Word.Application")
$objWord.Visible = 0
$objEmailOptions = $objWord.EmailOptions
$objSignatureObject = $objEmailOptions.EmailSignature
$objSignatureObject.NewMessageSignature = "Signature"
$objSignatureObject.ReplyMessageSignature = "Signature"
$objWord.Quit 0
|
|
Top
|
|
|
|
#200238 - 2010-10-12 09:07 AM
Re: vCard attach to a Outlook Signature
[Re: Arend_]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Good first go at translating, but you need to fix up the ridiculous VB "quotes within quotes" semantics:
$htmlfile.WriteLine(" <img src=""image002.png"" width=""124"" height=""38"" alt="""">")
|
|
Top
|
|
|
|
#200242 - 2010-10-12 07:30 PM
Re: vCard attach to a Outlook Signature
[Re: Richard H.]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
I did a literal translation, as I always do. If I fix things up, people won't learn properly
|
|
Top
|
|
|
|
#200245 - 2010-10-13 11:53 AM
Re: vCard attach to a Outlook Signature
[Re: Arend_]
|
Michael_Schou
Just in Town
Registered: 2010-10-11
Posts: 3
Loc: Denmark
|
Thx for the cleanup I was one of my colleagues that created the script and I'm not the code nerd you guys are I must inform you 
Any clues on how to auto add the vCard thingy in the signature ?
|
|
Top
|
|
|
|
#200265 - 2010-10-15 07:44 AM
Re: vCard attach to a Outlook Signature
[Re: Mart]
|
Michael_Schou
Just in Town
Registered: 2010-10-11
Posts: 3
Loc: Denmark
|
I will look into it.
Thx for the help so far
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 878 anonymous users online.
|
|
|