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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying the updated record from table file in outlook email

Status
Not open for further replies.

ninjaman01

Programmer
Aug 11, 2021
14
PH
Hi Everyone,

I have updated this application to include the emprole and rollevel fields in the dbf file, I can now update and send the file thru the email, however I want to include the updated record from the file to the email body, anyone knows how? I tried multiple methods but it won't fix my problem.
this is my code for the procedure of sending the email.
Code:
 select employee
   copy to &mfile2 field company,dept,cempno,empno,emptype,name,position,fname,lname,mi,; &&copied the fields from employee.dbf to mfile2.dbf
      birthdate,bank,promoid,from,to,bankac,exemp,base,basedte,base15,base15dte,base30,;
      base30dte,cola,coladte,cola15,cola15dte,cola30,cola30dte,erpag,otrate,adjustment,;
      workdays,sssno,tan,sex,cvstatus,provadd,cityadd,degreecs,rate,emprole,rollevel,branch,;
      baseflag for ltrim(str(dept,fsizeccno)) $ mdept;
      
   copy to &tmpcount for ltrim(str(dept,fsizeccno)) $ mdept and dltype = 1 and alltrim(dldesc) = "UPLOAD"
   replace dltype with 2, dldesc with "DOWNLOADED" for ltrim(str(dept,fsizeccno)) $ mdept and dltype =1 and alltrim(dldesc) = "UPLOAD"
   use &mfile2 alias mfile2 in 0 shared
   select mfile2
   
   create cursor tempstru(company N(1), dept N(fsizeccno), empno n(6), jobtype C(1),;
         name C(30), fname c(15), mi c(2), lname c(15),;
         bdate d(8), bank c(4), promoid c(1), from d(8), to d(8),;
         bankac c(15), exemp c(3), base n(8,2), basedte d(8), base15 n(8,2), base15dte d(8),;
         base30 n(8,2), base30dte d(8), cola n(8,2), coladte d(8), cola15 n(8,2), cola15dte d(8),;
         cola30 n(8,2), cola30dte d(8), otreg n(8,2), otsun n(8,2), othol n(8,2), otsphol n(8,2),;
         tleghol n(8,2), otspleghol n(8,2), nprem n(8,2), wtax n(8,2), wtax30 n(8,2),;
         sss n(8,2), sss30 n(8,2), medicare n(8,2), med30 n(8,2), pagibig n(8,2), pagibig30 n(8,2),;
         sssloan n(8,2), sssloan30 n(8,2), pibigloan n(8,2), pibig30 n(8,2), advances n(8,2), advance30 n(8,2),;
         otherinc n(8,2), otherded n(8,2), other30 n(8,2),;
         erpag n(8,2), adjustment n(8,2), workdays n(2),;
         sssno c(15), tan c(20), position c(20), sex c(1), civstat c(2),;
         dcola n(2), dabsent n(2), pin c(14), gender c(2), shift c(2), ersss n(8,2),;
         ermed n(8,2), erecc n(8,2), lastbase n(8,2), lastgross n(8,2), skill n(1),;
         rate n(15,2), education c(30), address1 c(40), address2 c(40), otrate n(7,2),; 
         branch c(15),emprole c(30), rollevel n(1))
         
    select tempstru
	  copy to &tempemp stru
	  use
	  use &tempemp alias tempemp in 0 shared
	     sele mfile2
		   go top
		   do while .not. eof()
		      mjobtype = ""
		      mcempno = cempno
		      
		      if !empty(rate)
	            xbase = rate
	            xrate = round(xbase/8,2) 
	         else
	            xbase = round((base*12)/313,2)
	            xrate = round(xbase/8,2)
	         endif
		      
		      if baseflag = "1" or (empty(baseflag) and UPPER(ALLT(emptype)) = "DIRECT")
                 xbase = 0
		         xrate = 0
		      endif
		      
		      sele tempemp
		      locate for str(empno) = mcempno
		      if !found()
		         sele tempemp
		         appe blank
		         repl empno with val(mcempno)
		      endif
		      
		      do case 
                    case mfile2.emptype = "DIRECT"
                       mjobtype = "R"
                    case mfile2.emptype = "KMC PROD"
                       mjobtype = "K"
                    case mfile2.emptype = "GREAT VALUE" .or. mfile2.emptype = "GV OFC" .or. mfile2.emptype = "GV PROD"
                       mjobtype = "G"
                    otherwise
                       mjobtype = "A"
              endcase
              replace company with mfile2.company, dept with mfile2.dept, jobtype with mjobtype,;  &&iif(ALLT(UPPER(mfile2.emptype)) = "DIRECT","R","A")
		              name with SUBSTR(ALLT(mfile2.name),1,30), fname with SUBSTR(ALLT(mfile2.fname),1,15), mi with mfile2.mi, lname with mfile2.lname,;
		              bdate with mfile2.birthdate, bank with mfile2.bank, promoid with mfile2.promoid, tempemp.from with mfile2.from, to with mfile2.to,;
		              bankac with mfile2.bankac, exemp with mfile2.exemp,;
		              base with xbase, basedte with mfile2.basedte, base15 with 0,;
		              base15dte with mfile2.base15dte, base30 with 0, base30dte with mfile2.base30dte, cola with mfile2.cola,;
		              coladte with mfile2.coladte, cola15 with mfile2.cola15, cola15dte with mfile2.cola15dte, cola30 with mfile2.cola30, cola30dte with mfile2.cola30dte,;
		              erpag with mfile2.erpag, otrate with mfile2.otrate, ;
		              adjustment with mfile2.adjustment, workdays with val(substr(allt(str(mfile2.workdays)),1,2)), sssno with mfile2.sssno, tan with mfile2.tan,;
		              position with SUBSTR(ALLT(mfile2.position),1,20), sex with mfile2.sex, civstat with mfile2.cvstatus, gender with allt(mfile2.sex), rate with xrate,;
		              education with substr(allt(mfile2.degreecs),1,30), address1 with SUBSTR(ALLT(mfile2.cityadd),1,40), address2 with SUBSTR(ALLT(mfile2.cityadd),41,80),;
		              branch with mfile2.branch, emprole with mfile2.emprole, rollevel with mfile2.rollevel
		         select mfile2
		         skip
		      enddo
		  select tempemp
		  copy to &mfile type foxplus
          run 7z a &mzip &mfile
          erase &mfile
          use &tmpcount alias tmpcount in 0 shared
          select tmpcount
          index on cempno to &emp
          if thisform.dtyp = "ftp"
             copy file &mzip to &mtopath
             thisform.emailbody3
          else
             thisform.emailattach3
          endif
 
I think we would need to see the code related to thisform.emailbody3 and thisform.emailattach3

As an aside, and not to criticise your code at all, you might want to look at your macro substitutions (&mfile, &mzip etc)
and consider converting them to character expressions where possible.

It might not be relevant to your case, but if one of those variables ends up with a space in it your copy to &mfile (for example) would fail.

It (for example) could be written

Code:
**copy to &mfile type foxplus && macro subst method could be:
copy to (mfile) type foxplus

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Not sure how relevant the last index on... tag &emp is... so I left that

Code:
SELECT employee
COPY TO (mfile2) FIELDS company,dept,cempno,empno,emptype,NAME,position,fname,lname,mi,; &&copied the fields from employee.dbf to mfile2.dbf
birthdate,bank,promoid,FROM,TO,bankac,exemp,BASE,basedte,base15,base15dte,base30,;
	base30dte,cola,coladte,cola15,cola15dte,cola30,cola30dte,erpag,otrate,adjustment,;
	workdays,sssno,TAN,sex,cvstatus,provadd,cityadd,degreecs,rate,emprole,rollevel,branch,;
	baseflag FOR LTRIM(STR(dept,fsizeccno)) $ mdept;

COPY TO (tmpcount) FOR LTRIM(STR(dept,fsizeccno)) $ mdept AND dltype = 1 AND ALLTRIM(dldesc) = "UPLOAD"
REPLACE dltype WITH 2, dldesc WITH "DOWNLOADED" FOR LTRIM(STR(dept,fsizeccno)) $ mdept AND dltype =1 AND ALLTRIM(dldesc) = "UPLOAD"
USE (mfile2) ALIAS mfile2 IN 0 SHARED
SELECT mfile2

CREATE CURSOR tempstru(company N(1), dept N(fsizeccno), empno N(6), jobtype C(1),;
	NAME C(30), fname c(15), mi c(2), lname c(15),;
	bdate d(8), bank c(4), promoid c(1), FROM d(8), TO d(8),;
	bankac c(15), exemp c(3), BASE N(8,2), basedte d(8), base15 N(8,2), base15dte d(8),;
	base30 N(8,2), base30dte d(8), cola N(8,2), coladte d(8), cola15 N(8,2), cola15dte d(8),;
	cola30 N(8,2), cola30dte d(8), otreg N(8,2), otsun N(8,2), othol N(8,2), otsphol N(8,2),;
	tleghol N(8,2), otspleghol N(8,2), nprem N(8,2), wtax N(8,2), wtax30 N(8,2),;
	sss N(8,2), sss30 N(8,2), medicare N(8,2), med30 N(8,2), pagibig N(8,2), pagibig30 N(8,2),;
	sssloan N(8,2), sssloan30 N(8,2), pibigloan N(8,2), pibig30 N(8,2), advances N(8,2), advance30 N(8,2),;
	otherinc N(8,2), otherded N(8,2), other30 N(8,2),;
	erpag N(8,2), adjustment N(8,2), workdays N(2),;
	sssno c(15), TAN c(20), position c(20), sex c(1), civstat c(2),;
	dcola N(2), dabsent N(2), pin c(14), gender c(2), SHIFT c(2), ersss N(8,2),;
	ermed N(8,2), erecc N(8,2), lastbase N(8,2), lastgross N(8,2), skill N(1),;
	rate N(15,2), education c(30), address1 c(40), address2 c(40), otrate N(7,2),;
	branch c(15),emprole c(30), rollevel N(1))

SELECT tempstru
COPY TO (tempemp) STRU
USE
USE (tempemp) ALIAS tempemp IN 0 SHARED
SELE mfile2
GO TOP
DO WHILE .NOT. EOF()
	mjobtype = ""
	mcempno = cempno

	IF !EMPTY(rate)
		xbase = rate
		xrate = ROUND(xbase/8,2)
	ELSE
		xbase = ROUND((BASE*12)/313,2)
		xrate = ROUND(xbase/8,2)
	ENDIF

	IF baseflag = "1" OR (EMPTY(baseflag) AND UPPER(ALLT(emptype)) = "DIRECT")
		xbase = 0
		xrate = 0
	ENDIF

	SELE tempemp
	LOCATE FOR STR(empno) = mcempno
	IF !FOUND()
		SELE tempemp
		APPE BLANK
		REPL empno WITH VAL(mcempno)
	ENDIF

	DO CASE
		CASE mfile2.emptype = "DIRECT"
			mjobtype = "R"
		CASE mfile2.emptype = "KMC PROD"
			mjobtype = "K"
		CASE mfile2.emptype = "GREAT VALUE" .OR. mfile2.emptype = "GV OFC" .OR. mfile2.emptype = "GV PROD"
			mjobtype = "G"
		OTHERWISE
			mjobtype = "A"
	ENDCASE
	REPLACE company WITH mfile2.company, dept WITH mfile2.dept, jobtype WITH mjobtype,;  &&iif(ALLT(UPPER(mfile2.emptype)) = "DIRECT","R","A")
	NAME WITH SUBSTR(ALLT(mfile2.NAME),1,30), fname WITH SUBSTR(ALLT(mfile2.fname),1,15), mi WITH mfile2.mi, lname WITH mfile2.lname,;
		bdate WITH mfile2.birthdate, bank WITH mfile2.bank, promoid WITH mfile2.promoid, tempemp.FROM WITH mfile2.FROM, TO WITH mfile2.TO,;
		bankac WITH mfile2.bankac, exemp WITH mfile2.exemp,;
		BASE WITH xbase, basedte WITH mfile2.basedte, base15 WITH 0,;
		base15dte WITH mfile2.base15dte, base30 WITH 0, base30dte WITH mfile2.base30dte, cola WITH mfile2.cola,;
		coladte WITH mfile2.coladte, cola15 WITH mfile2.cola15, cola15dte WITH mfile2.cola15dte, cola30 WITH mfile2.cola30, cola30dte WITH mfile2.cola30dte,;
		erpag WITH mfile2.erpag, otrate WITH mfile2.otrate, ;
		adjustment WITH mfile2.adjustment, workdays WITH VAL(SUBSTR(ALLT(STR(mfile2.workdays)),1,2)), sssno WITH mfile2.sssno, TAN WITH mfile2.TAN,;
		position WITH SUBSTR(ALLT(mfile2.position),1,20), sex WITH mfile2.sex, civstat WITH mfile2.cvstatus, gender WITH ALLT(mfile2.sex), rate WITH xrate,;
		education WITH SUBSTR(ALLT(mfile2.degreecs),1,30), address1 WITH SUBSTR(ALLT(mfile2.cityadd),1,40), address2 WITH SUBSTR(ALLT(mfile2.cityadd),41,80),;
		branch WITH mfile2.branch, emprole WITH mfile2.emprole, rollevel WITH mfile2.rollevel
	SELECT mfile2
	SKIP
ENDDO
SELECT tempemp
COPY TO (mfile) TYPE FOXPLUS
STRTOFILE('7z a "'+mzip+'" "'+mfile+'"'","c:\temp\myfile.bat")
RUN c:\temp\myfile.bat
ERASE (mfile)
ERASE c:\temp\myfile.bat
USE (tmpcount) ALIAS tmpcount IN 0 SHARED
SELECT tmpcount
INDEX ON cempno TO &emp
IF THISFORM.dtyp = "ftp"
	COPY FILE (mzip) TO (mtopath)
	THISFORM.emailbody3
ELSE
	THISFORM.emailattach3
ENDIF

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Ninjaman01,

The code that you posted does not help us answer your question. Your code appears to be creating or extracting the data that you want to send in the email, which is fine. But in order to help you get the data into the body of the message, we have to know what method you are using to create and send the email.

For example, are you using Outlook Automation? Or CDO? Or a thrid-party utility? Or ShellExecute() Or what? We need to know that in order to help you.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike

I think the clues to those are all buried in the forms methods emailbody3 and emailattach3 - perhaps there is an emailsend3?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi All,

I already resolved my concern, as for your questions yes the other codes are in the other procedures, thanks a lot to your help and tips.

Have a nice day,

Ninjaman01
 
I guess we won't see then

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top