Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Data from spreadsheet 1

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I am using the following code to send an email with contents from the spreadsheet from the push of a button:

Code:
Sub Button13_Click()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
.To = "XXXX@XXXX.com"
.CC = ""
.BCC = ""
.Subject = ""
.Body = Range("A8").Text & Range("B8").Text & Range("A21").Text & Range("b21").Text
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

I would like to have the information that goes into the body of the email separated by a carriage return or new line but i cannot figure out how to do it.

looking to do the following:

.Body = Range("A8").Text & Range("B8").Text (carriage return here so the next cells are on a new line) Range("A21").Text & Range("b21").Text

Thank you in advance for any help or suggestions.

Paul
 
Like this ?
.Body = Range("A8").Text & Range("B8").Text [!]& vbCrLf [/!]& Range("A21").Text & Range("b21").Text

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV that worked, I was not putting in the & before the vbCrLf. One question however, when i do this the first cell appears correctly but anything after it shows indented in the body of the email....example:

CELL1
CELL2
CELL3

Any way I can get them to line up?

Thanks again!

Paul
 
Thanks PHV! I realize that my last post didnt make sense because the editor automatically lined up my typing. The problem was just a formatting issue in my spreadsheet, thanks again for the help it worked great!

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top