VBS Script that inserts a url rather than an image

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

strMobile = objUser.Mobile

strWebAddress = ""

Logo = ""

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
    LVL 8

    Expert Comment

    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

    LVL 8

    Expert Comment

    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

    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.
    LVL 8

    Expert Comment

    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

    Outlook 2003 and Outlook 2007

    Accepted Solution

    no solution found

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
    Outlook Free & Paid Tools
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    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 …

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now