VBS Script that inserts a url rather than an image

Posted on 2009-02-13
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

Question by:stl-it
  • 3
  • 3

Expert Comment

ID: 23645969
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


Expert Comment

ID: 23645996
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


Author Comment

ID: 23645997
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.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 23646029
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.

Author Comment

ID: 25357333
Outlook 2003 and Outlook 2007

Accepted Solution

stl-it earned 0 total points
ID: 25535427
no solution found

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
This article will help to fix the below errors for MS Exchange Server 2016 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question