Solved

vfp9 elapsed time

Posted on 2013-01-15
4
621 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 42

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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Make the most of your online learning experience.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

690 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