Hi there
I need some help in creating the body of an email that I'm generating in excel.
The basic idea is that I create an email with HTML body, displaying a table made up of values that are located in cells A1:B5.
I can get the values in column A to appear fine, but if I try to change the str from A1:A5 to A1:B5 I get an error ?
Also I'd like the table to have a border and be nicely spaced out however am having difficulty in achieving this.
My current attempt is as below (am still very new to this VBA stuff so excuse the poor coding) ;o) - any help will be greatly appreciated.
Many thanks
G
I need some help in creating the body of an email that I'm generating in excel.
The basic idea is that I create an email with HTML body, displaying a table made up of values that are located in cells A1:B5.
I can get the values in column A to appear fine, but if I try to change the str from A1:A5 to A1:B5 I get an error ?
Also I'd like the table to have a border and be nicely spaced out however am having difficulty in achieving this.
My current attempt is as below (am still very new to this VBA stuff so excuse the poor coding) ;o) - any help will be greatly appreciated.
Many thanks
G
Code:
Sub GMtest()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim strTo As String
Sheets("Sheet1").Select
Range("A1").Select
strTo = Join$(Application.Transpose(Range("A1:A5").Value), "
")
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "xxx"
.Subject = "Test mail " & Date
.HTMLBody = "This is a test"
[B]
[B] .Attachments.Add ActiveWorkbook.FullName[/B]
[B] .Display[/B]
[B] End With[/B]
[B] On Error GoTo 0[/B]
[B] Set OutMail = Nothing[/B]
[B]cleanup:[/B]
[B] Set OutApp = Nothing[/B]
[B] Application.ScreenUpdating = True[/B]
[B]End Sub[/B]
[/B]