[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1010
  • Last Modified:

VBS Outlook 2000 / 2003 Default Email Signature

Hi,

I have a script which is creating a default email signature for users by pulling information from Active Directory. The script works fine, but I want to know how to set the signature as the default signature from within the script.

The code below works for outlook 2003 if I add it to the script, but generates an error for outlook 2000.

Anyone know what I need to change / what the problem is?

Set objWord = CreateObject(Word.Application)
objWord.Visible = false
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
objSignatureObject.NewMessageSignature = Default

Open in new window

0
thinkjim
Asked:
thinkjim
1 Solution
 
thinkjimAuthor Commented:
below is the entire script
Set objUser = CreateObject("WScript.Network")
userName = objUser.UserName
domainName = objUser.UserDomain 
 
FUNCTION GetUserDN(BYVAL UN, BYVAL DN)
Set ObjTrans = CreateObject("NameTranslate")
objTrans.init 1, DN
objTrans.set 3, DN & "\" & UN
strUserDN = objTrans.Get(1)
GetUserDN = strUserDN
END FUNCTION
 
Set objLDAPUser = GetObject("LDAP://" & GetUserDN(userName,domainName))
 
'Prepare to create some files
Dim objFSO, objWsh, appDataPath, pathToCopyTo, plainTextFile, plainTextFilePath, richTextFile, richTextFilePath, htmlFile, htmlFilePath, jobtitle
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWsh = CreateObject("WScript.Shell")
appDataPath = objWsh.ExpandEnvironmentStrings("%APPDATA%")
pathToCopyTo = appDataPath & "\Microsoft\Signatures\"
 
'asks for user input
jobtitle = InputBox("Hello! Please enter your job title for your email signature")
 
'sets as default signature
Set objWord = CreateObject("Word.Application")
objWord.Visible = false
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
objSignatureObject.NewMessageSignature = "Default"
 
 
'Let's create the plain text signature
plainTextFilePath = pathToCopyTo & "Default.txt"
Set plainTextFile = objFSO.CreateTextFile(plainTextFilePath, TRUE)
plainTextFile.WriteLine("-- ")
plainTextFile.WriteLine(objLDAPUser.DisplayName)
plainTextFile.WriteLine(jobtitle)
plainTextFile.WriteLine("Company Name")
plainTextFile.WriteLine(" ")
plainTextFile.WriteLine("t: +49 (0) 123456 " )
plainTextFile.WriteLine("f: +49 (0) 123456 " )
plainTextFile.WriteLine("e: " & objLDAPUser.mail)
plainTextFile.Write("w: www.company.com" )
plainTextFile.WriteLine(" ")
plainTextFile.WriteLine("This email and any of its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of the company. If you are not the intended receipient, any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited. Please contact the sender if you believe you have received this email in error. " )
plainTextFile.Close
 
'Now we create the Rich Text signature
richTextFilePath = pathToCopyTo & "Default.rtf"
Set richTextFile = objFSO.CreateTextFile(richTextFilePath, TRUE)
richTextFile.WriteLine("{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fswiss\fcharset0 Verdana;}}")
richTextFile.WriteLine("\viewkind4\uc1\pard\f0\fs20 -- \par")
richTextFile.WriteLine(objLDAPUser.DisplayName & "\par")
richTextFile.WriteLine(jobtitle & "\par")
richTextFile.WriteLine("the company" & "\par")
richTextFile.WriteLine ("\par")
richTextFile.WriteLine("t: +49 (0) 123456 "  & "\par")
richTextFile.WriteLine("f: +49 (0) 123456 "  & "\par")
richTextFile.WriteLine("e: " & objLDAPUser.mail & "\par")
richTextFile.WriteLine("w: www.company.com " & "\par")
richTextFile.WriteLine ("\par")
richTextFile.WriteLine("This email and any of its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of the company. If you are not the intended receipient, any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited. Please contact the sender if you believe you have received this email in error. " & "\par")
richTextFile.Write("}")
richTextFile.Close
 
'And finally, the HTML signature
htmlFilePath = pathToCopyTo & "Default.htm"
Set htmlFile = objFSO.CreateTextFile(htmlFilePath, TRUE)
htmlfile.WriteLine("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">")
htmlfile.WriteLine("<html xmlns=""http://www.w3.org/1999/xhtml"" >")
htmlfile.WriteLine("<body>")
htmlfile.WriteLine("<div style=""font-size:10pt; font-family:'Verdana','helvetica';"">")
htmlfile.WriteLine("<div>-- </div>")
htmlfile.WriteLine("<div>" & objLDAPUser.DisplayName & "</div>")
htmlfile.WriteLine("<div>" & jobtitle & "</div>")
htmlfile.WriteLine("<div>Company Name" & "</div>")
htmlfile.WriteLine("<div>&nbsp;" & "</div>")
htmlfile.WriteLine("<div>t: +49 (0) 123456" & "</div>")
htmlfile.WriteLine("<div>f: +49 (0) 123456" & "</div>")
htmlfile.WriteLine("<div>e: <a href="" & objLDAPUser.mail & "">" & objLDAPUser.mail & "</a></div>")
htmlfile.WriteLine("<div>w: <a href=""http://www.company.com"">www.company.com</a></div>")
htmlfile.WriteLine("<div>&nbsp;" & "</div>")
htmlfile.WriteLine("<div>This email and any of its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of the company. If you are not the intended receipient, any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited. Please contact the sender if you believe you have received this email in error." & "</div>")
htmlfile.WriteLine("</div>")
htmlfile.WriteLine("</body>")
htmlfile.Write("</html>")
 
Wscript.Echo "Script Completed"

Open in new window

0
 
David LeeCommented:
Hi, thinkjim.

This should do it.  You'll call it like this

    SetSignature "MySingnatureName"
Sub SetSignature(strSignatureName as String)
    Dim arrVersion as Variant
    arrVersion = Split(Outlook.Application.Version, ".")
    Set objShell = CreateObject("WScript.Shell")
    objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\" & arrVersion(0) & ".0\Common\MailSettings\NewSignature" , strSignatureName
    objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\" & arrVersion(0) & ".0\Common\MailSettings\ReplySignature" , strSignatureName
    Set objShell = Nothing
End Sub

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now