Dobut in sending mail thru VBA

gopdeep

Board Regular
Joined
Apr 24, 2012
Messages
94
pls have a luk on below code
Rich (BB code):
Private Sub CommandButton1_Click()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim rng As Range
    Dim str As String, str1 As String
    Dim in1 As String, in2 As String
    in1 = InputBox("Range1:")
    in2 = InputBox("Range2:")
    Set rng = Sheets("sheet1").Range(in1 & ":" & in2).SpecialCells(xlCellTypeVisible)
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    strbody = ActiveSheet.Range(in1 & ":" & in2).Select
    str = "<font face='Trebuchet MS' size=2 color=blue >" & "Hi All," & "<br><br>" & "Good Morning !!!" & "<br><br>" & "Please find today's allocation below:" & "<br><br>" & "</font>"
    str1 = "<font face='Trebuchet MS' size=2 color=blue >" & "Thanks," & "<br>" & "GopDeep" & "</font>"
    On Error Resume Next
        With OutMail
        .To = "gopdeep@aaa.com"
        .CC = "gopdeep1@aaa.com"
        .BCC = ""
        .Subject = "Sample" & Chr(32) & Range("H4") & " Mail it is"
        .HTMLBody = str & RangetoHTML(rng) & "<br><br>" & str1
        .Display
        .ReadReceiptRequested = True
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

above code is working fine, but in mail body table is not appearing properly.

that is last row of the table is not having line in it... i couldn't resolve it even after many try... pls :help: me
 
Your code worked for me (with Ron de Bruin's RangetoHTML function). Make sure that the last row in the selected range has a bottom border rather than the row below having a top border.
 
Upvote 0
It works for me if row 17 has a double bottom border, but not if there's a double top border in the row below. Try removing (what appears to be) the bottom border and adding it again.
 
Upvote 0
:confused:

its not working to me... borders lines table whatever it is... everything perfect only... no double line at bottom or top...

can you share me your document to have a look...
 
Upvote 0

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