Use API to implement mass mail in VFP

xiaoxiao2021-03-06  123

Use API to implement mass mail in VFP

Author: Xie ancient and modern

Contact your email with friends, customer or relatives, have become very popular. Implementing email functions in the management system is clearly a wise move that is suitable for users and market development needs. Of course, it is not difficult to implement email functions, and implement a bulk mail sending function is a greater practical measure. We are fully considering such demand, fully considering such demand, completely considering such demand and fully considering the mass mail transmission. Of course, implementing such a function requires a Windows API function, and many users may feel that the API is very mysterious, and I don't dare to try it easily. In fact, the API function is very powerful, and the implementation of many functions is not. In fact, you can master a certain law, the API is not so difficult. The following brief explains how to implement it.

Batch mail sending forms (as shown)

Contains four command buttons ("Select Mail Table", "Confirm Mail List", "Go to Mail Processor", "Exit"), two tags, a drop-down combo box, an edit box, a text box (with The pull-down combination frame is combined). The process is like this: the program first detects whether there is an open table, if there is, no prompt, no prompts that have not been opened, you can click "Select Include Mail Table", select a data table to open. In the future, you can select a field containing the email address from the drop-down combo box, and then click the "OK Mail List", filter the qualified mail address, which appears in the edit box. If you want to delete or add an email address, you can do it in the edit box. Next click "Go to Mail Processor", these email addresses will be accepted as "Recipient" by the system default mail acceptance and sender such as Foxmail, Outlook and other programs, and the message editing window appears in the edit window. It can be convenient to write a letter! Hereinafter, the core code will be described in turn.

"Select the Moiled Men" Mouse Click Event Code:

M.cfilename2 = getFile ("dbf") && display file opens the selection window, select a DBF file

IF file (m.cfilename2) = .t.

                                        

Else

Return

MendiF

THISFORM.CBOMAILZIDUAN.ROWSOURCETYPE = 8 && Determines the data source type as the table structure

THISFORM.CBOMAILZIDUAN. ROWSource = CFileName2 && Determining Data Source Name

  drop-down combination box CBOMAILZIDUAN mouse Click Event Code:

ISform.txtmailziduan.value = thisform.cbomailziduan.value

"Confirm Mail List" Mouse Click Event Code:

IF DBF (1) == ''

IF MessageBox ("No open table, please select the included mail table retry!", 64, "Mail Processing" = 1

Return

MendiF

MendiF

DO FORM FRM Find && uses a lookup form provided by the VFP itself to construct a lookup form. Conditional records will be utilized by the following procedures.

Browse Nomenu NOEDIT Nodelete && Shows Meeting Conditional Record

M.lcemail = Upper (alltrim (thisform.txtmailziduan.value) && gets email field name

M. Lmailok = .f.

                          FOR i = 1 to fcount 

IF M.LCemail <> Field (i) 

Else

M. Lmailok = .t.

Exit

MendiF

Mendfor

IF m.Lmailok == .f.

  IF MessageBox ("There is no field in the table, please modify the field name and try!", 64, "Mail Processing" = 1

Return

MendiF

MendiF

To && In the following block, the eligible data will be output to a text file. Read the text content into the Edtmaillist Edit box for editing modifications.

IF File ("Mailist.txt") = .t.

Delte File Mailist.txt && If the temporary file already exists, then delete it first.

MendiF

Copy to Maillist Fields & Lcemail Type Delimited with Blank

  onemail = fopen ("maillist.txt")

M.cmail = ''

      read the block address of the email address.

DO While .Not. Feof (Handlemail)

M.cmail = Alltrim (FGETS (Handlemail) ',' M.cmail

Menddo

ISform.edtmaillist.Value = m.cmail

FClose (Handlemail)

IF File ("Mailist.txt") = .t.

Delete File Maillist.txt

MendiF

Return

"Go to Mail Processor" Mouse Click Event Code:

                                                         ?

Return

  form of Activate event code:

Set procedure to xgjudf

IF DBF (1) == ''

IF MessageBox ("No open table, please select the included mail table retry!", 64, "Mail Processing" = 1

Return

MendiF

MendiF

THISFORM.CBOMAILZIDUAN.ROWSOURCEPE = 8 && Specifies the data source type of the drop-down combo box.

Bisform.cbomailziduan.rowsource = Alias ​​(1) && Specifies the data source of the drop-down combo box.

  xgjfileopen () function in xgjudf

******** 

Function Description: Use the shellexecute function in the API to call the open program handling file, if the .doc file is opened with Word, send your email using the default mail processor.

Parameter M.cxgjFileName Represents the name of the file, such as sending M.cxgjfilename = "way: labman2001@sina.com", open the RTF file to write m.cxgjfilename = "c: / documents and settings / xgj / my documents / Customer .rtf "

******** 

Function XGJFileOpen ()

Parameter m.cxgjfilename

&& Declaration SHELLEXECUTE functions

Declare Integer shellexecute in shell32.dll integer hwnd,; "String LPSZOP,;

String lpszfile,;;

String lpszparams,;  

String lpszdir,;;

Indinteger fsshowcmd

&& Declaration GetDeskTopWindow function, this function activates Windows desktop

Declare Integer GetDesktopWindow in Win32API

&& specifies to run the shellexecute function from the Windows desktop

                                                                                                                                                 ?

LLPSZOP = ""

"&& designated the file for SHELLEXECUTE operations for mailto: labman2001@sina.com

LLPSZFILE = Alltrim (m.cxgjfilename) 

LLPSZPARAMS = ""

  Specify the default directory of shellexecute c: /

LLPSZDIR = "C: /"

FSSHOWCMD = 1

&& Execute SHELLEXECUTE commands

LLNRETURN = SHELLEXECUTE (HWND, LPSZOP, LPSZFILE, LPSZPARAMS, LPSZDIR, FSSHOWCMD)                                                                

转载请注明原文地址:https://www.9cbs.com/read-126473.html

New Post(0)