oWordDocument = createobject("Word.Application") >with oWordDocument > .Documents.Add("c:\mypath\mysavedtemplate.doc") && New file with a template > with .Activedocument > _SetVar("cFirst_Name", myTable.First_name) > _SetVar("cLast_Name", myTable.Last_name) >*... > endwith >*... > .Visible = .t. && Show word >endwith > > >FUNCTION _SetVar >LPARAMETERS tcVarName, tcVarValue > .Variables(tcVarName).value = iif(empty(tcVarValue)," ",tcVarValue)This works pretty well for one record templates (or Parent table data).
strSubject = "Quotation No.: "+ALLTRIM(QTHD.QUOTENO) theApp = CreateObject("Outlook.Application") theNameSpace = theApp.GetNameSpace("MAPI") *theNameSpace.Logon(strProfile , strPassword) theMailItem = theApp.CreateItem(0) *theMailItem.Recipients.Add( strRecipient ) theMailItem.Subject = strSubject theMailItem.Body = test() *theMailItem.Font.name = "Fixedsys" theMailItem.display theNameSpace.Logoff FUNCTION test REQUERY("QUOTEVW") m.Description = "Requested By:"+SPACE(2)+ALLTRIM(QTHD.REQUESTED_)+CHR(13)+; "Inquiry No.:"+SPACE(2)+ALLTRIM(QTHD.INQUIRY_NO)+CHR(13)+; "Inquiry Date:"+SPACE(2)+DTOC(QTHD.INQUIRY_DA)+CHR(13)+; "Date:"+SPACE(2)+DTOC(QTHD.DATE)+CHR(13)+; "Estimated Delivery:"+SPACE(2)+ALLTRIM(QTHD.ESTIMATED_)+CHR(13)+; "Terms:"+SPACE(2)+ALLTRIM(QTHD.TERMS)+CHR(13)+; "Salesman:"+SPACE(2)+ALLTRIM(QTHD.SALESMAN)+CHR(13)+CHR(13)+CHR(13)+; "Quantity"+SPACE(20)+"Description"+SPACE(20)+; "Umeas"+SPACE(10)+"Amount"+CHR(13) SELECT QUOTEVW FOR I = 1 TO RECCOUNT() GO RECORD I m.description = m.description+STR(QUOTEVW.QUANTITY)+; SPACE(2)+QUOTEVW.DESCRIPTION+SPACE(2)+QUOTEVW.UMEAS+; SPACE(2)+STR(QUOTEVW.AMOUNT,10,2)+CHR(13) ENDFOR m.Description = m.Description+CHR(13)+CHR(13)+CHR(13) m.Description = m.Description+QTHD.OTHER_INFO RETURN m.Description ENDFUNCAs you can see I can have a lot of items or just one. Got any Ideas?