Outlook emailing

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
Why is it that this code will show the signature ONLY if I enable .display? I'd like to just .send without .display.

TECH:
This loops through rows 2-3 and creates an Outlook mail object, to which it adds to,cc,bbc,subject,body and then emails

Code:
Sub Mail_Outlook_With_Signature_Html_1()
' Working in Office 2000-2016
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    
For x = 2 To 3
tostr = Sheet1.Cells(x, "a")
ccopy = Sheet1.Cells(x, "b")
bcopy = Sheet1.Cells(x, "c")
substr = Sheet1.Cells(x, "d")
strbody = Sheet1.Cells(x, "e")


    'On Error Resume Next
Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
        .Display
        .to = tostr
        .CC = ccopy
        .BCC = bcopy
        .Subject = substr
        .HTMLBody = strbody & "<br>" & .HTMLBody
        .Send
    End With
'On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
Next x
    MsgBox "test"
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I add signature this way:

Code:
 With OutMail
        .Display
        .to = tostr
        .CC = ccopy
        .BCC = bcopy
        .Subject = substr
    
         sPath = Environ("appdata") & "\Microsoft\Signatures\Bob.htm"
         sSignat = GetSignature(sPath)
      
         .HTMLBody =strBody &  String(4, vbCrLf) &  sSignat
 
        .Send
    End With
    Set OutMail = Nothing
End Sub


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
 
Last edited:
Upvote 0
I'll give it a try, but I notice your Outmail code is still enabling .display. Please test to see if it works with .display disabled. '.display Thanks
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,937
Members
449,196
Latest member
Maxkapoor

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