Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Control To Email VFP report?
Message
From
15/10/2004 15:40:09
 
 
To
15/10/2004 14:34:55
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00951809
Message ID:
00951831
Views:
5
>Looking for a control to email vfp7 report as a mail body or attached file(s) to a specific address(s) at run time. Please advice.

Hi Yury,

Here is a simple sample of how to take a standard VFP report and convet it into text that can be added to the body of an out going email.
* WIDTH of the file created ( You decide based on testing )
_ASCIICOLS = 120
* Your cursor holding the records to display in the report.
SELECT Report_cursor
GO TOP
* Create the report at a text file.
REPORT FORM YourReport.frx TO FILE rptfile ASCII

* Gets the search path for the file
lcRptFile = FOPEN("rptfile.txt", 10)
* If the file open ok.
IF lcRptFile <> -1
    * Loop through all the lines of text in the file.
    DO WHILE !FEOF(lcRptFile)
        NOTE: This section will loop through the text file.
        *     What you do with the text is up to you. You will
        *     be formatting the body of the email based on the
        *     report that was saved as a text file.

        * Store the full line from file into this variable.
        lcTempString = ALLTRIM(FGETS(lcRptFile))

        * For purposes of this explaination -> store that line into this variable. Adding the charrage return & line feed.
        lcBodyString = lcTempString + CHR(13) + CHR(10)
    ENDDO

    =FCLOSE(lcRptFile)
    =FFLUSH(lcRptFile)

    * If the text file exists. ( Which it will. Unless deleted mannually. )
    IF FILE('rptfile.TXT')
        * Get rid of the file.
        DELETE FILE rptfile.txt
    ENDIF
ENDIF

* Now the variable 'lcBodyString' can be used in the body of the email to send.
From here you can use simple OutLook automation to send the email.

HTH
Mike
Previous
Reply
Map
View

Click here to load this message in the networking platform