D
dantee
Hi Ron.
No, it is not. I'm trying something simpler... just emailing the contents
on a spreadsheet worksheet, and your code makes the email the but is failing
to put the contents of the sheet on the email body...
..HTMLBody = RangetoHTML(rng)
doesn't seem to be working (I did copy the RangetoHTML function into the
same module as the macro). Perhaps the problem may be my settings in
Outlook? Any help would be great. Here is your code, which I am using:
Sub Mail_Sheet_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set rng = Nothing
Set rng = ActiveSheet.UsedRange
'You can also use a sheet name
'Set rng = Sheets("YourSheet").UsedRange
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = RangetoHTML(rng)
.Display 'or use .Send
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Sincerely,
Dante
No, it is not. I'm trying something simpler... just emailing the contents
on a spreadsheet worksheet, and your code makes the email the but is failing
to put the contents of the sheet on the email body...
..HTMLBody = RangetoHTML(rng)
doesn't seem to be working (I did copy the RangetoHTML function into the
same module as the macro). Perhaps the problem may be my settings in
Outlook? Any help would be great. Here is your code, which I am using:
Sub Mail_Sheet_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set rng = Nothing
Set rng = ActiveSheet.UsedRange
'You can also use a sheet name
'Set rng = Sheets("YourSheet").UsedRange
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = RangetoHTML(rng)
.Display 'or use .Send
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Sincerely,
Dante