Originally Posted by
gmayor
GetSignature is not a variable. It's a call to a function, which presumably you didn't copy along with the rest of the macro.
Thanks very much for the response GMayor. You are exactly correct. GetSignature is a function that was posted separately to the main sub (I should have seen it if I opened my eyes!!). Here is the Function and full Sub in question if anyone needs it.
Note: It will not display an image if it is part of your signature. I am marking this thread as solved.
Function GetSignature(fPath As String) As String
Dim fso As Object
Dim TSet As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set TSet = fso.GetFile(fPath).OpenAsTextStream(1, -2)
GetSignature = TSet.readall
TSet.Close
End Function
Sub With_HTML_Signature()
'Do not forget to change the email ID
'before running this code
Dim OlApp As Object
Dim NewMail As Object
Dim EmailBody As String
Dim StrSignature As String
Dim sPath As String
Set OlApp = CreateObject("Outlook.Application")
Set NewMail = OlApp.CreateItem(0)
' Here Since we are talking about
' the HTML email then we need to
' write the Body of the Email in
' HTML.
EmailBody = "Hello Friends !!" & "<br><br>Welcome to LearnExcelMacro.com" & vbNewLine & _
"Here i will make you awesome in Excel Macro.<br><br>You can mail me at info@learnexcelmacro.com"
'*****************************************************
' Important
'*****************************************************
' go to the appdata path as mentioned in
' the above important point. Check the name of
' the signature file. For example: here in my system
' the signature's file name is vish.txt, vish.htm
' Therefore before running this code, check the
' name fo the signature file in your system and
' replace vish.txt with your file name.
'****************************************************
sPath = Environ("appdata") & "\Microsoft\Signatures\DesSig.htm"
' If the path and file name given by you is not
' correct then code you insert a blank Signature
If Dir(sPath) <> "" Then
StrSignature = GetSignature(sPath)
Else
StrSignature = ""
End If
On Error Resume Next
With NewMail
.To = "info@learnexcelmacro.com"
.CC = "info@learnexcelmacro.com"
.BCC = "info@learnexcelmacro.com"
.Subject = "Type your Subject here"
' Here at the end of the Email Body
' HTML Signature is inserted.
.htmlBody = EmailBody & "<br><br>" & StrSignature
'.send
.display
End With
On Error GoTo 0
Set NewMail = Nothing
Set OlApp = Nothing
End Sub