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

inserting variables into automated emailer 2

Status
Not open for further replies.

clmcdade

Programmer
Joined
Oct 4, 2001
Messages
6
Location
US
I have a small patch of code that is intended to send "statements" to a list extracted from a table. However, I seem to be missing something when inserting the variables from the table into the emailer. Can anyone help me with this? Thank you, Chris

Here is the code :

** This application will append two files into tables and use these
** tables to automatically send email to the recipients on the list.
** CM - Oct 8, 2001
clear all
close all
#DEFINE ccMAINPATH "s:\chris\jill"
#DEFINE ccNOTIFY_EMAIL "cmcdade@bcsmemphis.com"


wait wind "testing testing testing" timeout 3

public oEmailer

cd ccMAINPATH
oEmailer=createobject("emaildll.emailer")

******************
** Selection section **
set step on
use stmtlist excl
sele * from stmtlist right join asocemal on textfile==filename ;
wher !empty(textfile) ;
into curs temp
sele * from temp where left(dest,1) != "*" && deselects fax and print files
** send email from the temp file **
goto top
do while !EOF()
stmtfile=allt(textfile)
recipient=allt(dest)
**do emailnotify
**proc EmailNotify
? oEmailer.sendmail(recipient, ;
"Monthly Statement", "stmt attached", ;
stmtfile)
skip
enddo
 
1. Use SCAN ENDSCAN iso DO WHILE !EOF() ENDDO and the GOTO TOP will also be redundent.
2. Have you checked if the SQL select resulted in a cursor with records (_TALLY > 0)

3. sele * from temp where left(dest,1) != "*"
shouldn't this be selected into a cursor ?

HTH,
Weedz (Wietze Veld)
My private project:Download the CrownBase source code !!
 
I thought I would try a different approach and use the following code ... however, I get the following message :
"exception code 4096. cannot add attachment; no data source was provided."

Here is the code excerpt

use stmtlist excl
sele * from stmtlist right join asocemal on textfile==filename ;
wher !empty(textfile) ;
into curs temp
sele * from temp where left(dest,1) != "*" && deselects fax and print files
** send email from the temp file **
goto top
do while !EOF()
filepath="s:\chris\jill\"
stmtfile=allt(textfile)
recipient=allt(dest)

o=createobject("outlook.application")
oitem=o.createitem(0)
oitem.subject="Test Email From VFP6"
oitem.to=(recipient)
oitem.body="This mail was sent from vfp using Outlook2k"
oitem.Attachments.Add=(stmtfile)
oitem.send
o=.null.
skip
enddo
 
Try to code more robust and put in checks, check if files are there, if records are there etc.

Are you sure the string you attach represents a file ?

HTH,


Weedz (Wietze Veld)
My private project:Download the CrownBase source code !!
 
One addition:

Put in:

IF FILE(stmtfile) && check if the file is there
oitem.Attachments.Add=(stmtfile)
ENDIF

HTH,

Cheers.
Weedz (Wietze Veld)
My private project:Download the CrownBase source code !!
 
Hi Christopher

IF FILE(stmtfile) && check if the file is there
oitem.Attachments.Add(stmtfile)
** Note the = sign is removed... Weedz slipped on that
ENDIF

Hope his works for you. :-)

Ramani
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top