
getting Excel data into body
If objWS is your Worksheet object, objWS.Cells(j,k) returns the value in the cell in the jth row and the kth column, e.g. Cells(1,1) for the first cell. So, if your data is in the first three columns of rows 6-11, you could build a string like this:
strData = ""
For j = 1 to 2
For k = 6 to 11
strData = strData & " " & objWS.Cells(j, k)
Next
strData = Trim(strData) & vbCrLf
Next
MyText = "Here's your information:" & Chr(13)
MyText = MyText & strData & "the end"
.Body = MyText
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.slipstick.com/books/jumpstart.htm
Quote:
> I am using Automation to run Outlook from Excel. In the
> past I have always sent the Excel file as an attachment.
> What I want to do now is get the Excel data into the body
> of the mail item. What I want the body to look like is:
> Here's your information:
> <Excel data line1>
> <Excel data line2>
> <etc. . .>
> the End
> What I currently have:
> MyText = "Here's your information:" & Chr(13)
> MyText = MyText & "the end"
> .Body = MyText
> I can't figure out how to get the Excel data between the
> first MyText and the second MyText, but I think I'm going
> down the wrong path.
> Thanks,
> Dion