Page 1 of 1 1
Topic Options
#200231 - 2010-10-11 11:31 AM vCard attach to a Outlook Signature
Michael_Schou Offline
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_ Moderator Offline
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 \:\)

 Code:
; 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:&nbsp;</td>")
$htmlfile.WriteLine("							<td>" + $objLDAPUser.otherTelephone + "</td>")

; Direct Phone Number
If NOT $objLDAPUser.TelephoneNumber = ""
  $htmlfile.WriteLine("							<td>&nbsp;|</td>")
  $htmlfile.WriteLine("							<td>&nbsp;Direkte:&nbsp;</td>")
  $htmlfile.WriteLine("							<td>" + $objLDAPUser.TelephoneNumber + "</td>")
Else
  $htmlfile.WriteLine("							<td>&nbsp;</td>")
  $htmlfile.WriteLine("							<td>&nbsp;</td>")
  $htmlfile.WriteLine("							<td>&nbsp;</td>")
EndIf
$htmlfile.WriteLine("						</tr>")
$htmlfile.WriteLine("						<tr>")
$htmlfile.WriteLine("							<td>Telefax:&nbsp;</td>")
$htmlfile.WriteLine("							<td>" + $objLDAPUser.facsimileTelephoneNumber + "</td>")
If NOT $objLDAPUser.mobile = ""
  $htmlfile.WriteLine("							<td>&nbsp;|</td>")
  $htmlfile.WriteLine("							<td>&nbsp;Mobil:&nbsp;</td>")
  $htmlfile.WriteLine("							<td>" + $objLDAPUser.mobile + "</td>")
Else
  $htmlfile.WriteLine("							<td>&nbsp;</td>")
  $htmlfile.WriteLine("							<td>&nbsp;</td>")
  $htmlfile.WriteLine("							<td>&nbsp;</td>")
EndIf
$htmlfile.WriteLine("						</tr>")
$htmlfile.WriteLine("					</table>")
$htmlfile.WriteLine("					<br/>")
$htmlfile.WriteLine("					<a href=""mailto:" + $objLDAPUser.mail + """>" + $objLDAPUser.mail + "</a>")
$htmlfile.WriteLine("					&nbsp;|&nbsp;")
$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 Offline
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:
 Code:
$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_ Moderator Offline
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 Offline
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
#200246 - 2010-10-13 12:30 PM Re: vCard attach to a Outlook Signature [Re: Michael_Schou]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
We are looking into creating a vCard for everyone following a template that uses the company standard guidelines for font types, sizes and colors, uploading to a website and inserting a images with a link on it in the signatures so people can download and save the vCard if they want. A lot of companies block vCards as attachment (*.vcf files) so adding it by default is in my opinion not the "cleanest" option.

vCards are plain text and therefore can be created with a simple script that uses the writeline function and add data from let’s say AD to get the user specific stuff. We use the Word com object to create the signatures and below is part of the script that adds a picture and sets a hyperlink on it.

Word/Outlook 2003:
 Code:
...
$objShape = $objSelection.InlineShapes.AddPicture(@LDRIVE +  "\tools\Images\vcard.gif")
$objLink = $objDoc.Hyperlinks.Add($objShape, "http://www.website.com/user.vcf")
...


Word/Outlook 2007
 Code:
...
$objShape = $objSelection.InlineShapes.AddPicture(@LDRIVE +  "\tools\Images\vcard.gif")
$objLink = $objDoc.Hyperlinks.Add($objShape, "http://www.website.com/username.vcf",,, "Download my contact data as a vCard")
...


Edited by Mart (2010-10-14 09:14 AM)
Edit Reason: Typo in the code. Thanks Arend.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#200248 - 2010-10-13 06:16 PM Re: vCard attach to a Outlook Signature [Re: Mart]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Mart you forgot the closing bracket in the Word/Outlook 2003 example.
Top
#200252 - 2010-10-14 09:14 AM Re: vCard attach to a Outlook Signature [Re: Arend_]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Fixed. Thanks.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#200265 - 2010-10-15 07:44 AM Re: vCard attach to a Outlook Signature [Re: Mart]
Michael_Schou Offline
Just in Town

Registered: 2010-10-11
Posts: 3
Loc: Denmark
I will look into it.

Thx for the help so far \:\)

Top
#200275 - 2010-10-16 02:18 PM Re: vCard attach to a Outlook Signature [Re: Michael_Schou]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Have any of you looked at this Vault article that deals with creating Outlook signatures from AD? It doesn't do .VCF, but all the logic is there to add a new format pretty easily instead of re-inventing the wheel.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 878 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.063 seconds in which 0.024 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org