Solved

vfp9 elapsed time

Posted on 2013-01-15
4
615 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript errors in VFP form using oleControl 9 968
dedupe in foxpro 12 480
@ ... say c_Symbol in Visual Foxpro 9.0 SP2 in Windows 8 5 472
DBF to ... Converter 5 110
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…
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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