I have a screen in an application which allows users to select a number of email recipients from a table, and then to open up the user’s default mail client inserting the selected email addresses into the ‘to’, ‘cc’ or ‘bcc’ fields as appropriate. The user can then write the email text and send out the email in due course. It is a very simple process, and I do not need VFP to send the email.
The application is written in VFP9 SP2, and until recently all users were using Thunderbird as the mail client. Most machines are Windows XP, some are using Windows 7. I need a generic routine (ie not specific to Outlook 2003) as I do not know the email client for a given user.
The code below has worked perfectly for some years, but some users have now switched to Outlook 2003, using Word 2003 as the text editor, and although a new email document is still opened correctly, the recipient addresses are not put in. Am I missing something obvious?
*PREPARE FOR USING SHELLEXECUTE TO CALL EXTERNAL APPLICATIONS
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
**************************
* BUILD ADDRESS STRING TO SEND TO OPEN EMAIL CLIENT ROUTINE
SELECT massem && Table of recipients email addresses (field=’ownemail’),
COPY TO ARRAY aNms FIELDS ownemail FOR send=.t.
cAdds=""
GO top
* Build string of email addresses
FOR i=1 TO ALEN(aNms)
cAdds=cAdds+ALLTRIM(aNms)+","
ENDFOR
* Throw away last comma
cAdds=ALLTRIM(cAdds)
cAdds=LEFT(cAdds,LEN(cAdds)-1)
* User will have already selected whether recipients are 'To', 'CC', or 'BCC'.
* Build appropriate string
DO case
CASE thisform.optAddress.Value=1
cList="?To="
CASE thisform.optAddress.Value=2
cList="?CC="
CASE thisform.optAddress.Value=3
cList="?BCC="
ENDCASE
cList=cList+cAdds
=mail(1,cList)
**************************
PROCEDURE mail
PARAMETERS nDowhat,cAddresslist,
cAddresslist=alltrim(cAddresslist)
DO CASE
CASE nDowhat=1 && CREATE NEW EMAIL
cFileName = "mailto:"+cAddresslist
cAction = "open"
cParams=""
cDir=""
ENDCASE
errno=ShellExecute(0,cAction,cFileName,cParams,cDir,1)
The application is written in VFP9 SP2, and until recently all users were using Thunderbird as the mail client. Most machines are Windows XP, some are using Windows 7. I need a generic routine (ie not specific to Outlook 2003) as I do not know the email client for a given user.
The code below has worked perfectly for some years, but some users have now switched to Outlook 2003, using Word 2003 as the text editor, and although a new email document is still opened correctly, the recipient addresses are not put in. Am I missing something obvious?
*PREPARE FOR USING SHELLEXECUTE TO CALL EXTERNAL APPLICATIONS
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
**************************
* BUILD ADDRESS STRING TO SEND TO OPEN EMAIL CLIENT ROUTINE
SELECT massem && Table of recipients email addresses (field=’ownemail’),
COPY TO ARRAY aNms FIELDS ownemail FOR send=.t.
cAdds=""
GO top
* Build string of email addresses
FOR i=1 TO ALEN(aNms)
cAdds=cAdds+ALLTRIM(aNms)+","
ENDFOR
* Throw away last comma
cAdds=ALLTRIM(cAdds)
cAdds=LEFT(cAdds,LEN(cAdds)-1)
* User will have already selected whether recipients are 'To', 'CC', or 'BCC'.
* Build appropriate string
DO case
CASE thisform.optAddress.Value=1
cList="?To="
CASE thisform.optAddress.Value=2
cList="?CC="
CASE thisform.optAddress.Value=3
cList="?BCC="
ENDCASE
cList=cList+cAdds
=mail(1,cList)
**************************
PROCEDURE mail
PARAMETERS nDowhat,cAddresslist,
cAddresslist=alltrim(cAddresslist)
DO CASE
CASE nDowhat=1 && CREATE NEW EMAIL
cFileName = "mailto:"+cAddresslist
cAction = "open"
cParams=""
cDir=""
ENDCASE
errno=ShellExecute(0,cAction,cFileName,cParams,cDir,1)