Solved

vfp9 elapsed time

Posted on 2013-01-15
4
567 Views
Last Modified: 2013-01-18
Hi Experts

I am sending email using
loMail = Newobject("Cdo2000", "Cdo2000.fxp")

it works fine
What I would like to display is the real clock while it is sending the email so I can inform
approximate finishing time.
0
Comment
Question by:b001
  • 3
4 Comments
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 38780203
This class? http://www.berezniker.com/content/pages/visual-foxpro/cdo-2000-class-sending-emails

Do you send multiple mails?
If not, the only code line sending the mail is This.oMsg.Send(), it's second to the last line of the Send() method.

And that line is executed and vfp code continues after the mail was sent. So there is no way to display a clock and update it, while the mail is sent. The next time you can update the clock is, after the mail was sent.

If you want to send to multiple recipients (without using the BCC to do this with one mail), then you could update a clock or progress bar with each mail sent. As you surely know how many recipients you have, this also means you can compute the percentage of the progress and compute time remaining from time elapsed.  

So, what's your loop?

Bye, Olaf.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 38780332
Another idea:

You can make a seperate mailer.PJX, use the cdo2000 class there and call it in your app via RUN /N mailer.exe. Then send the mails in mailer.exe and your application will continue right away. This means sending mails is "outsourced" as a background process.

That way it doesn't matter much, how the progress is, your user can continue working in your app right away.

Bye, Olaf.
0
 
LVL 41

Expert Comment

by:pcelba
ID: 38780739
I am using just an animated GIF picture during the mail sending.

You may create a small form displaying the clock: http://support.microsoft.com/kb/140290

Of course, the clock updates cannot go smoothly because the sending program executes in the same Windows thread. To execute it in a separate thread (as Olaf suggested) would be a solution but it needs additional coding.
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 38781702
The other EXE would be a simple project with just a main.prg and cdo2000.prg

LPARAMETERS tcRecipientsDBF, tcMailTemplate

SET PROCEDURE TO cdo2000

Local loMail, lcMail
USE (tcRecipientsDBF)
SCAN
   loMail = CreateObject("Cdo2000")
   loMail.cTo = recipient && this must be field of the DBF passed in as file name in tcRecipientsDBF
   lcMail = TextMerge(tcMailTemplate) && could merge in recipients fields into the mail text
   loMail.cTextBody = lcMail
   *... whatever else you do with each mail goes here, eg setting smpt server, port, user, password...
   loMail.Send()
ENDSCAN

Open in new window


And your main application just needs to seperate the recipients list as a dbf and put in mail adress in a recipient field plus any other info you want to merge into a template mail text.

Then you might add some error handling, add a field sent to the recipients DBF and set it to .F. for mails, which failed, whatever. But it's not much of a change needed.

Usage:
TEXT To lcMailtext NoShow
Dear <<customername>>,

we have new offers...visit us on www.ourgreatshopasyouknowitandloveit.com
ENDTEXT
RUN /N mailer.exe WITH "d:\customers.dbf", lcMailtext

Open in new window


customers.dbf needs a field recipient (with mail address) and customername (with full name) in this case. But you know yourself how you use the loMail class and set it's  properties.

Bye, Olaf.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now