Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 644
  • Last Modified:

vfp9 elapsed time

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
b001
Asked:
b001
  • 3
1 Solution
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
pcelbaCommented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now