Can't Get Send Mail to Add Signature

Anne Troy

MrExcel MVP
Joined
Feb 18, 2002
Messages
2,632
Office Version
  1. 365
Platform
  1. Windows
I'm using a bunch of code that VoG helped me with (VoG is a GoD!), and adding some Ron De Bruin (another GoD) code. Everything works except adding the html signature. Yes, the file exists in the path shown.

Code:
Function GetBoiler(ByVal sFile As String) As String
'**** Kusleika
    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

Sub FinalEmail()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range
    Dim strbody As String
    Dim SigString As String 'Anne
    Dim Signature As String 'Anne


    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
          Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
            With OutMail
         .To = Range("'Dashboard'!D3").Text
         .CC = Range("'Dashboard'!D4").Text & ";" & Range("'Dashboard'!D5").Text & Range("adminemail").Text
         .BCC = Range("'Dashboard'!D6").Text

        .Subject = "XXXXX POS Order Update: " & Range("merchantname").Text & " " & Range("merchantmid").Text
        .Body = Range("'Email Text'!$C$15").Text & Chr(10) & Chr(10) & _
        Range("'Email Text'!$C$16").Text & Chr(10) & _
        Range("'Email Text'!$C$17").Text & Chr(10) & _
        Range("'Email Text'!$C$18").Text & Chr(10) & _
        Range("'Email Text'!$C$19").Text & Chr(10) & _
        Range("'Email Text'!$C$20").Text & Chr(10) & _
        Range("'Email Text'!$C$21").Text & Chr(10) & _
        Range("'Email Text'!$C$22").Text & Chr(10) & _
        Range("'Email Text'!$C$23").Text & Chr(10) & _
        Range("'Email Text'!$C$24").Text & Chr(10) & _
        Range("'Email Text'!$C$25").Text & Chr(10) & _
        Range("'Email Text'!$C$26").Text & Chr(10) & _
        Range("'Email Text'!$C$27").Text & Chr(10) & _
        Range("'Email Text'!$C$28").Text & Chr(10) & _
        Range("'Email Text'!$C$29").Text & Chr(10) & _
        Range("'Email Text'!$C$30").Text & Chr(10) & _
        Range("'Email Text'!$C$31").Text & Chr(10) & _
        Range("'Email Text'!$C$32").Text & Chr(10) & _
        Range("'Email Text'!$C$33").Text & Chr(10) & _
        Range("'Email Text'!$C$34").Text & Chr(10) & Chr(10)
                
    SigString = "C:\Users\atroy\AppData\Roaming\Microsoft\Signatures\AnneTroyHT.htm"

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

              
            If Range("'Dashboard'!G10").Text = "Hospitality" Then
            
            With OutMail

                .Attachments.Add ("C:\SendingFiles\MerchantHelperApplication.xlsx")
                .Attachments.Add ("C:\SendingFiles\MenuOrganization.xlsx")
                .Display  'Or use Send
            End With
            
            ElseIf Range("'Dashboard'!G10").Text = "Retail" Then
                 
            With OutMail

            If Range("'Dashboard'!G10").Text = "Retail" Then

                .Attachments.Add ("c:\SendingFiles\RetailStandardImport.xlsx") ' you will need to add the correct file name here
                .Display
            End If
            

        
    End With
    
    
    End If
    
On Error GoTo 0
  Set OutMail = Nothing
        
cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End With
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
You never actually append Signature to the Body property - probably because you aren't reading the signature into the variable until after you set the Body property. (didn't we have this discussion before? ;))
 
Upvote 0
I think so. And I said I'm no programmer. I'm stealing. I have NO idea what you're talking about. :)
 
Upvote 0
I think rorya is saying your code is out of order. ie you included one part too early.
The code below should come before the line "With OutMail"
Then to put the the signature in the body you would have something like...
.Body = "blahblahblah" & vbCrLf & Signature

Code:
    SigString = "C:\Users\atroy\AppData\Roaming\Microsoft\Signatures\AnneTroyHT.htm"

    If Dir(SigString) <> "" Then
        Signature = GetBoiler(SigString)
    Else
        Signature = ""
    End If
 
Last edited:
Upvote 0
So I got the code to compile, but instead of seeing my beautiful html signature graphic, I get all the html code that makes up my signature. why???
 
Upvote 0
use the property ".HTMLBody" instead of ".Body"
But for some reason, the pictures in my signature aren't displayed.
And the hard returns using "vbCrLf" are not executed.
 
Last edited:
Upvote 0
If using HTML you need BR tags rather than linefeeds.
 
Upvote 0
None whatsoever, I'm afraid. I always use templates for this as it's easier.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top