VBA .send vs .display signature

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
In my code snippet below I am checking checkbox2 to see if the user wants to display the email before sending. If TRUE, just send without display. Unfortunately if it sends without display, the person's default signature doesn't get included in the email. WHY??? I don't understand. Please help thanks.

Code:
    With OlMail
If Trim(mySender) <> "" Then
.SentOnBehalfOfName = mySender
End If
If mailform.CheckBox2.Value = False Then
.display
End If
.To = recips
.Subject = stSubject
.HTMLBody = vaMsg & Signature & "
" & .HTMLBody
If mailform.CheckBox2.Value = True Then
.Send
End If
    End With
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
.
What about this ? Does it help or have you already tried it ?

Code:
Option Explicit


With OlMail


    If Trim(mySender) <> "" Then
        .SentOnBehalfOfName = mySender
    End If
    
    If mailform.CheckBox2.Value = False Then
        .display
    End If
    
    .To = recips
    .Subject = stSubject
    .HTMLBody = vaMsg & Signature & "" & .HTMLBody
    
    If mailform.CheckBox2.Value = True Then
        .HTMLBody = vaMsg & Signature & "" & .HTMLBody
    .Send
    End If
    
End With
 
Upvote 0
Thanks Logit. Sorry I've tried that and it didn't work. However, if I add this I can get the signature to show but not the image within the signature:

Code:
sPath = Dir(Environ("appdata") & "\Microsoft\Signatures\*.htm", vbNormal)
        sPath = Environ("appdata") & "\Microsoft\Signatures\" & sPath
        sSignat = GetSignature(sPath)
.HTMLBody = myBody & sSignat '& "<br>" & .HTMLBody
 
Upvote 0
Oops, here's the function it calls:

Code:
Function GetSignature(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)
    GetSignature = ts.readall
    ts.Close
End Function
 
Upvote 0
.
One way I've been able to add an image to a Signature is to provide the actual path to the image.
 
Upvote 0
.
Try this. Note the instructions in the code :

Code:
Dim ImagePath As String     '<-- Place in your Dim Statements at top




ImagePath = ThisWorkbook.Path & "\Your Image Name.jpg" '<-- Place after Dim Statements




sPath = Dir(Environ("appdata") & "\Microsoft\Signatures\*.htm", vbNormal)
        sPath = Environ("appdata") & "\Microsoft\Signatures\" & sPath
        sSignat = GetSignature(sPath)
.HTMLBody = myBody & sSignat '& "" & .HTMLBody & "

" & _
        "

 

" & "[IMG]https://www.mrexcel.com/forum/" & ImagePath & "[/IMG]"

As written, the image must be in the same folder as the workbook. Otherwise you'll need to change the path to the image :
Code:
ImagePath = ThisWorkbook.Path & "\Your Image Name.jpg"

Also, the image does not need to be a .JPG ... it can be a .BMP image as well. I haven't tried a .PNG but I'm guessing that might work as well.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,595
Members
452,657
Latest member
giadungthienduyen

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