We help IT Professionals succeed at work.

VBS Script that inserts a url rather than an image

stl-it asked
Medium Priority
Last Modified: 2012-05-06
I created a vb script that pulled information from Active Directory and created an Outlook signature with the information. It works perfectly and took me quite a while to get it to this point. The only issue that I'm running into is that the script is inserting the image into the email, rather than a pointer, so the image gets sent as an attachment. I want the vb script to insert html code instead of inserting the image.  To clarify, I then want Outlook to send the link to the recipient instead of the image itself.  I've tried several different ways and haven't been able to get it to work.  
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strName = objUser.FullName
strTitle = objUser.Title
strFName = objUser.FirstName
strLName = objUser.LastName
strInfo = objUser.info
strMobile = objUser.Mobile
strWebAddress = "www.companyinc.com"
Logo = "http://www.companyinc.com/pages/images/pages/companylogo.jpg"
strDepartment = objUser.Department
strAddress = objUser.StreetAddress
strCity = objUser.l
strState = objUser.St
strPostalCode = objUser.PostalCode
strPhone = objUser.telephoneNumber
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
objSelection.Font.Name = "Verdana"
objSelection.Font.Color = "000,000,000"
objSelection.Font.Italic = false
objSelection.Font.Bold = true
objSelection.Font.Size = "10"
objSelection.TypeText strFName
objSelection.TypeText " " & strLName
objSelection.TypeText "" & strInfo
objSelection.Font.Name = "Verdana"
objSelection.Font.Color = "000,000,000"
objSelection.Font.Italic = false
objSelection.Font.Bold = false
objSelection.Font.Size = "9"
objSelection.TypeText strTitle 
objSelection.Hyperlinks.Add strWebAddress
objSelection.TypeText strAddress    
objSelection.TypeText " | "
objSelection.TypeText strCity
objSelection.TypeText ", " & strState
objSelection.TypeText " " & strPostalcode
objSelection.TypeText strPhone
objSelection.TypeText " (Office) | " &strMobile
objSelection.TypeText " (Cell)"
objSelection.TypeText "Visit us on the web @ "
Set hyp = objSelection.Hyperlinks.Add(objSelection.Range, strWebAddress, "", "", strWebAddress)
hyp.Range.Font.Size = "9"
hyp.Range.Font.Name = "Verdana"
Set objSelection = objDoc.Range()
objSignatureEntries.Add "company Signature", objSelection
objSignatureObject.NewMessageSignature = "company Signature"
objSignatureObject.ReplyMessageSignature = ""
objDoc.Saved = True

Open in new window

Watch Question

Instead of Line 51 insert these two lines. The first line adds the link ot the Logo and the second goes to the next line.

Is this what you were looking for?
Set hyp1 = objSelection.Hyperlinks.Add(objSelection.Range, Logo)

Open in new window

If you want the link to say something other than the full URL use the following.
Set hyp1 = objSelection.Hyperlinks.Add(objSelection.Range, Logo, , , "Our Company Logo")

Open in new window


I think that just makes the hyperlink appear rather than the image.   I think what I'm after is an embedded image rather than an image that is embedded and sent as an attachment. Hope that makes some sort of sense.
Sorry I understood you wanted to send as a URL...what client are you using? Outlook as your code works.

It might be a setting in Outlook you are looking for. In Tools..Options...Mail Format Tab. Click the Internet Format button as see if "When an HTML message contains pictures located on the Internet send a copy not the location" is checked.

If I uncheck mine it sends it as an attachment.


Outlook 2003 and Outlook 2007
no solution found

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.