Hi dears i have done a small VBA Code to send the current file as attachment through Outlook.
file is successfully attached and mail is been sent.
But my problem is i am unable to fill Body in Mail.
please find attached i want to select range A1:D18 in sheet (Table) as BODY to my Email.
code i mentioned below is not working. pls help
' .body = ActiveWorkbook.Sheets("Table").Range("A5")
.body = ActiveWorkbook.Sheets("Table").Range("A1:D18")
Option Explicit Sub Send_Email() Dim rng As Range Dim OutApp As Object Dim OutMail As Object Dim currentfile, i, finallength, curfile As String currentfile = ActiveWorkbook.FullName MsgBox currentfile With Application .EnableEvents = False .ScreenUpdating = False End With Set rng = Nothing On Error Resume Next Set rng = Selection.SpecialCells(xlCellTypeVisible) On Error GoTo 0 If rng Is Nothing Then MsgBox "Please select a range or the sheet is protected" & _ vbNewLine & "please correct and try again.", vbOKOnly Exit Sub End If Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = "[email protected]" .CC = "[email protected]" .Attachments.Add currentfile .Subject = "test" .body = ActiveWorkbook.Sheets("Table").Range("A5") ' .body = ActiveWorkbook.Sheets("Table").Range("A2:B19") .Display .Send End With On Error GoTo 0 With Application .EnableEvents = True .ScreenUpdating = True End With Set OutMail = Nothing Set OutApp = Nothing End Sub
Bookmarks