Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook VBA script will not display HTML footer images

Status
Not open for further replies.

DVHITMAN

Technical User
Jun 19, 2013
12
GB
hello,

I have written ( with a LOT of help from other people on) a VBs script that and on login that installs outlook footer depending on the users geographical location , and grabs the details from AD.

This all works faultlessly.

I'm now trying to "fix" an outlook VB script that, once run, checks the "to" field and brings up a reply email using the correct email signature, or if it cannot find the correct email signature, asks for which on to use.

Again, this works as it should..... however, the footers contain images stored on our webserver, and these are not displayed if the Outlook script tries to use the signature (if I access the signature manually, its displays ok ).

This is the code I am using :-



Sub SmartReply()

Dim Msg As Outlook.MailItem
Dim MsgReply As Outlook.MailItem
Dim strGreetName As String
Dim SignatureType As String
Dim SigString1 As String
Dim SigString2 As String
Dim SigString3 As String
Dim Spacer As String
Dim SendAsName
Dim strSentTo

SigString1 = "C:\Users\" & Environ("username") & _
"\AppData\Roaming\Microsoft\Signatures\Signature1.htm"

SigString2 = "C:\Users\" & Environ("username") & _
"\AppData\Roaming\Microsoft\Signatures\Signature2.htm"

SigString3 = "C:\Users\" & Environ("username") & _
"\AppData\Roaming\Microsoft\Signatures\Signature3.htm"

Spacer = "----------Original Message----------"


' set reference to open/selected mail item
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set Msg = ActiveExplorer.Selection.Item(1)
strSentTo = Msg.ReceivedByName

Case "Inspector"
Set Msg = ActiveInspector.CurrentItem
strSentTo = Msg.ReceivedByName
Case Else
End Select

If Msg Is Nothing Then GoTo ExitProc

If strSentTo = "TOM" Then
MsgBox "Hi TOM"
SigString = SigString2
SendAsName = "TOM"
ElseIf strSentTo = "DICK" Then
MsgBox "Hi DICK"
SigString = SigString1
SendAsName = "DICK"
ElseIf strSentTo = "HARRY" Then
MsgBox "Hi HARRY"
SigString = SigString3
SendAsName = "HARRY"
Else

SignatureType = InputBox("Cannot determine which signature to reply with." & vbCr & vbCr & "Type 'D' for DICK" & vbCr & " 'T' for TOM" & vbCr & " or 'H' for HARRY" & vbCr)
On Error GoTo 0

If SignatureType = "" Then GoTo ExitProc

Select Case SignatureType

Case "D", "d"
SigString = SigString1
SendAsName = "DICK"
Case "T", "t"
SigString = SigString2
SendAsName = "TOM"
Case "H", "h"
SigString = SigString3
SendAsName = "HARRY"
Case Else
MsgBox "You have selected an invalid choice (Silly Billy), so I now have nothing to do..."
GoTo ExitProc
End Select

End If

If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

Set MsgReply = Msg.Reply

With MsgReply

.Subject = "RE:" & Msg.Subject
.SentOnBehalfOfName = SendAsName
.HTMLBody = Signature & Spacer & .HTMLBody
.Display
End With


ExitProc:
Set Msg = Nothing
Set MsgReply = Nothing
End Sub

Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function

PLEASE, could someone help me a) figure out WHY this script will not show the inbedded image files in the e-mail signature, and b) how to fix it ?

Many Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top