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!

How to copy excel data to Outlook email body programmatically? 1

Status
Not open for further replies.

armadillo0

IS-IT--Management
Nov 18, 2005
8
SG
Hi Foxpro Expert,
Wow, time flies, seems almost 20 years since the last time I posted.

What I want to do is actually pretty simple, but have no solution to it at the moment.
Basically, I have excel data to copy and just paste it to the outlook body.
I tried with all the below syntax, but none is working, any clue what is the proper way to paste the clipboard data to outlook body?

Million thanks for your great assistance [pc2]

oExcel.Visible=.T.
oExcel.Range("A1").Activate
oExcel.Range("A1:C"+ALLTRIM(STR(nRow,9))).SELECT
oExcel.Range("A1:C"+ALLTRIM(STR(nRow,9))).copy

*oItem.body=oExcel.Range("A1:C"+ALLTRIM(STR(nRow,9))) &&"Testing....123"+CHR(13)
*oItem.HTMLbody=oExcel.Range("A1:C"+ALLTRIM(STR(nRow,9))).paste &&"Testing....123"+CHR(13)
*oItem.body.PasteSpecial()
oitem.display
oItem.HTMLbody="Press Ctrl-V now"+CHR(13)
*oItem.HTMLbody=_CLIPTEXT &&"Testing HTML..."+CHR(13)
oItem.HTMLbody.PasteSpecial &&=oExcel.GetText &&GetFromClipboard &&_CLIPTEXT &&"Testing HTML..."+CHR(13)
*oItem.HTMLbody=oItem.HTMLbody+_CLIPTEXT+CHR(13)
*oItem.PasteSpecial(1) &&.PasteSpecial(1)
 
This is something I have done in the past for pasting Excel Data into an Outlook email. I create a table in the body of the email and then just scan through the data to fill in all the data I want and have attached the excel file itself for good measure.

Code:
TRY
	o=CREATEOBJECT([outlook.application])
CATCH
	o=CREATEOBJECT([outlook.application.14])
ENDTRY
oitem=o.createitem(0)
oitem.subject=[****** AAAAAAA *****]
lto=[zzzzz@zzzzzzz.com]+lemail
lcc=[ffffffff@ffffffff.com]
oitem.TO=lto
oitem.cc=lcc
oitem.Attachments.ADD(lfile2)

lhtml=[]
lhtml=[<head><style> table, th, td {border: 1px solid black;border-collapse: collapse} th, td {padding: 1px} th {text-align: left} tr {text-align: left}</style></head>]
lhtml=lhtml+[<table border="1" style="width:100%">]
lhtml=lhtml+[<tr><th>AAAAAA</th><th>BBBBBB</th><th>CCCCCC</th><th>DDDDDDD</th><th>EEEEEEEEE</th><th>FFFFFFFFFFFFFF</th></tr>]

aaa=[]
bbb=[]
ccc=[]
ddd=[]
eee=[]
fff=[]

SCAN
laaa=aaa
lbbb=bbb
lccc=ccc
lddd=ddd
leee=eee
lfff=fff

lhtml=lhtml+[<tr><td>]+laaa+[</td><td>]+lbbb+[</td><td>]+lccc+[</td><td>]+lddd+[</td><td>]+leee+[</td><td>]+lfff+[</td></tr>]
ENDSCAN

lhtml=lhtml+[</table><footer> Info <br><br> ]
lhtml=lhtml+[ info <br> ]
lhtml=lhtml+[ info <br>  OR  <br>]
lhtml=lhtml+[ <br> ]+SYS(16)+[ </footer>]
oitem.htmlbody=lhtml
*oitem.DISPLAY
*cancel
oitem.SEND
o=.NULL.
 
Thank you @TinyNinja,
very details sample.
I will try out soon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top