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

Sending bulk email messages from VFP 6.0 and VFP 9

Ashwani Bansal

Programmer
Feb 27, 2024
4
0
1
HK
Can someone guide on sending out email message from VFP version 6.0 and VFP Version 9.0 app, I used ShellExecute lcmail in VFP Ver 6.0 but it does not work with some client email software like foxmail etc.

Please suggest any third party simple to integrate with VFP 6 or VFP 9 sending out bulk email
 
ShellExecute() with a mailto: link is not designed to actually send an email. It simply opens a composing window in the user's default email client. It is up to the user to actually click the Send button.

There are several approaches to actually sending an email, or multiple emails, automatically. If you browse the FAQs for this forum, you will see several articles that will point you in the right direction.

Mike
 
I've used quite a few platforms to send emails over the years. What I've come to realize is that regardless of how you push out the emails, just about every cloud based email service like Microsoft 365, Google, etc. put major restrictions on the volume and speed you can send.

For example, if you send more than X emails per minute, per hour, or per day, they reject the rest. Google / Gmail for example will stop sending at 100 emails. (See https://support.google.com/a/answer/166852?sjid=11466423543250032354-NA for details).

Basically, unless you have your own mail server, best practice is to use a relay service. I use Amazon's SES (Simple Email Service) for most of my transactional emails, so my clients can send out thousands of invoices without hitting any limits. For some of my clients who have their own IT department, I use SMTP.Com or SMTP2GO.Com.

The APIs vary a little from company to company, but most of them have a simple SMTP option to push the same credentials for every account at the same domain, with a few additional security options like limiting the sends to specific IPs.

Keep in mind although it gets rid of the send limits, unlike going directly through a user's SMTP credentials, the user does not see a copy in their Sent Folder. For those who still need that, you can Bcc them.
 
PS... If you are starting from scratch, there are quite a few ways to get mail out using things like CDO or ChilKat, but as I mentioned earlier, unless you have in-house servers, it's best you use a relay service that will ensure the mails go through without the sending limits.

Here are a couple of good starting points.


 
Carolx Programmer

How about sending emails using Outlook Automation with Bullzip printer for PDF attachment.
I was using the Mapi protocol to send pay slips by email but it is not working with Windows 11. I kept getting the message 'Mapi is not registered on this computer'. ChatGpt suggested that I use Outlook Automation instead. Below is the ChatGpt assisted code to send pay slips by email that includes Bullzip printer for the PDF attachment.

SET PRINTER TO NAME 'BULLZIP PDF PRINTER'
lcAttachment = ''
DO empslip IN pyempslipnew_1 WITH 17,"A","email",empno
SELECT earndedtmp

IF ADIR(laMail, lcPayslipfile) = 1
ERASE (lcPayslipfile)
ENDIF

lcPayslipfile = Textmerge('c:\email\payslip<<TRIM(empmail.empno)+DTOC(pycntrl.perdt,1)>>.pdf')

lcObj = CreateObject("BullZIP.PDFPrinterSettings")
lcObj.SetValue("Output", lcPayslipfile)
lcObj.SetValue("ShowSettings", "never")
lcObj.SetValue("ShowPDF", "no")
lcObj.WriteSettings(.t.)

REPORT FORM empslip14tmplate NOCONSOLE TO PRINTER

lcSec = SECONDS()
DO WHILE NOT ADIR(laMail, lcPayslipfile) = 1
IF SECONDS() - lcSec > 35
=MESSAGEBOX("PDF creation timeout", 16, 'Mailing Payslips')
RETURN
ENDIF
ENDDO

lcAttachment = (lcPayslipfile)

* Initialize Outlook application
oOutlook = CreateObject("Outlook.Application")

* Create a new mail item
oMailItem = oOutlook.CreateItem(0) && 0 represents MailItem
oMailItem.Subject = "Payslip for " + ALLTRIM(empmail.namef) + " " + ALLTRIM(empmail.namel)

myvar = " "
SET TEXTMERGE ON NOSHOW
SET TEXTMERGE TO MEMVAR myvar

\TO: <<TRIM(empmail.namef)>> <<TRIM(empmail.namel)>>
\
\Attached is your payslip for <<pcycle>> ending <<pycntrl.perdt>>.
\
\FROM: <<pycntrl.name>>

SET TEXTMERGE TO
SET TEXTMERGE OFF

oMailItem.Body = myvar
oMailItem.To = ALLTRIM(empmail.email)

* Add an attachment
oAttachmentPath = (lcPayslipfile)
IF FILE(oAttachmentPath)
oMailItem.Attachments.Add(oAttachmentPath)
ELSE
=MESSAGEBOX("Attachment file not found: " + oAttachmentPath, 16, 'Mailing Payslips')
RETURN
ENDIF

* Send the email
oMailItem.Send()

* Clean up
RELEASE oMailItem
RELEASE oOutlook

MESSAGEBOX("Email sent successfully!", 64, "Success")
 
I've used quite a few platforms to send emails over the years. What I've come to realize is that regardless of how you push out the emails, just about every cloud based email service like Microsoft 365, Google, etc. put major restrictions on the volume and speed you can send.

For example, if you send more than X emails per minute, per hour, or per day, they reject the rest. Google / Gmail for example will stop sending at 100 emails. (See https://support.google.com/a/answer/166852?sjid=11466423543250032354-NA for details).

Basically, unless you have your own mail server, best practice is to use a relay service. I use Amazon's SES (Simple Email Service) for most of my transactional emails, so my clients can send out thousands of invoices without hitting any limits. For some of my clients who have their own IT department, I use SMTP.Com or SMTP2GO.Com.

The APIs vary a little from company to company, but most of them have a simple SMTP option to push the same credentials for every account at the same domain, with a few additional security options like limiting the sends to specific IPs.

Keep in mind although it gets rid of the send limits, unlike going directly through a user's SMTP credentials, the user does not see a copy in their Sent Folder. For those who still need that, you can Bcc them.
Thank you Joe sharing your experience!
 
Carolx Programmer

How about sending emails using Outlook Automation with Bullzip printer for PDF attachment.
I was using the Mapi protocol to send pay slips by email but it is not working with Windows 11. I kept getting the message 'Mapi is not registered on this computer'. ChatGpt suggested that I use Outlook Automation instead. Below is the ChatGpt assisted code to send pay slips by email that includes Bullzip printer for the PDF attachment.

SET PRINTER TO NAME 'BULLZIP PDF PRINTER'
lcAttachment = ''
DO empslip IN pyempslipnew_1 WITH 17,"A","email",empno
SELECT earndedtmp

IF ADIR(laMail, lcPayslipfile) = 1
ERASE (lcPayslipfile)
ENDIF

lcPayslipfile = Textmerge('c:\email\payslip<<TRIM(empmail.empno)+DTOC(pycntrl.perdt,1)>>.pdf')

lcObj = CreateObject("BullZIP.PDFPrinterSettings")
lcObj.SetValue("Output", lcPayslipfile)
lcObj.SetValue("ShowSettings", "never")
lcObj.SetValue("ShowPDF", "no")
lcObj.WriteSettings(.t.)

REPORT FORM empslip14tmplate NOCONSOLE TO PRINTER

lcSec = SECONDS()
DO WHILE NOT ADIR(laMail, lcPayslipfile) = 1
IF SECONDS() - lcSec > 35
=MESSAGEBOX("PDF creation timeout", 16, 'Mailing Payslips')
RETURN
ENDIF
ENDDO

lcAttachment = (lcPayslipfile)

* Initialize Outlook application
oOutlook = CreateObject("Outlook.Application")

* Create a new mail item
oMailItem = oOutlook.CreateItem(0) && 0 represents MailItem
oMailItem.Subject = "Payslip for " + ALLTRIM(empmail.namef) + " " + ALLTRIM(empmail.namel)

myvar = " "
SET TEXTMERGE ON NOSHOW
SET TEXTMERGE TO MEMVAR myvar

\TO: <<TRIM(empmail.namef)>> <<TRIM(empmail.namel)>>
\
\Attached is your payslip for <<pcycle>> ending <<pycntrl.perdt>>.
\
\FROM: <<pycntrl.name>>

SET TEXTMERGE TO
SET TEXTMERGE OFF

oMailItem.Body = myvar
oMailItem.To = ALLTRIM(empmail.email)

* Add an attachment
oAttachmentPath = (lcPayslipfile)
IF FILE(oAttachmentPath)
oMailItem.Attachments.Add(oAttachmentPath)
ELSE
=MESSAGEBOX("Attachment file not found: " + oAttachmentPath, 16, 'Mailing Payslips')
RETURN
ENDIF

* Send the email
oMailItem.Send()

* Clean up
RELEASE oMailItem
RELEASE oOutlook

MESSAGEBOX("Email sent successfully!", 64, "Success")
Thank you Carlox
 
I recommend Chilkat ActiveX for sending emails, it's very reliable and has also several options for gmail's REST API etc. You need a commercial license, but Chilkat comes with a ton of other useful stuff (FTP, encryption, REST client etc.) and is way worth it. Plus you don't need Outlook or any other programm installed to send emails.
Here's an example code:

Another commercial solution specifically for VFP would be West Wind Internet and Client Tools, example: https://client-tools.west-wind.com/docs/_s9001zxj2.htm
It also comes with a lot of stuff that can be useful in the future.

Both are very easy to implement and there's a test version of both.

Regards,
Manni
 
I recommend Chilkat ActiveX for sending emails, it's very reliable and has also several options for gmail's REST API etc. You need a commercial license, but Chilkat comes with a ton of other useful stuff (FTP, encryption, REST client etc.) and is way worth it. Plus you don't need Outlook or any other programm installed to send emails.
Here's an example code:

Another commercial solution specifically for VFP would be West Wind Internet and Client Tools, example: https://client-tools.west-wind.com/docs/_s9001zxj2.htm
It also comes with a lot of stuff that can be useful in the future.

Both are very easy to implement and there's a test version of both.

Regards,
Manni
We use West Wind Internet and Client Tools as well for SMTP and it works extremely well.
You do need your own SMTP server and the tool box requires a nominal one time cost but well worth it.
 
Big fan of ChilKat

Not free, but you only pay once and it's well worth it
 
If by "bulk" you mean spam, I don't want to help you. But if you mean sending invoices or confirmation to existing customers, that is "kosher" 😂
I have a system where our local branches sends backups and a lot of other files to our HQ. When they have been processed by the HQ server I send an automatic confirmation email, which says either success or failure. The system does a test unpack of the zip-files and if that fails I don't process it further.

The emails are sent via BLAT, a free tool which can be used either with a command line interface or by ini-files (Google it).

BTW the software at HQ is called tha BBS, now at least some of you know how long this has been going on, 28 years and counting 😊
 

Part and Inventory Search

Sponsor

Back
Top