none
Sending SMS from VFP 9

    Question

  • Hello All,

    It is my desire that an Invoicing System that I developed in VFP 9 automatically sends a 'Thank you for visiting' message to a customer after an invoice is printed. Please how can I achieve this?

    Andrew Mordi

    Friday, January 13, 2012 12:59 AM

Answers

  • Hi Andrew

    you have Two Option

    1) Web Based SMS. SMS Provider Company provide you API to Send SMS using Internet Connection.

    2) GSM Modem. you can send SMS using AT Command via GSM Modem.

    Check below sample for AT Command 

    http://www.foxite.com/archives/how-can-i-send-sms-by-vfp6-0000066718.htm

    Regards

    Kalpesh


    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh 's Blog

    VFP Form to C#, Vb.Net Conversion Utility
    Friday, January 13, 2012 4:27 AM
    Answerer
  • Hi Andrew

    check below function to Execute your URL. there is three parameter 

    1) URL Name

    2) Result Required in STRING or FILE

    3) if Required File then  FILE Locaiton.

     

    Function ExecuteURL

    Lparameters lcgetUrl,FileOrStr,lcSaveUrl

     

    LOCAL lcQuote AS STRING,lcTempTxtFile AS STRING, lnGetResults AS INTEGER, lcURL AS STRING

    Local lcrtn

    lcQuote = ""

     

    *-- Set up a variable referring to a temp .TXT file.

    *-- Uses the current VFP TEMP DIR [SYS(2023)]

    *-- and a random file name [SYS(2015)]

    If Vartype(lcSaveURL)="L"

    lcTempTxtFile = FORCEEXT(ADDBS(SYS(2023)) + SYS(2015), "TXT")

    Else 

    lcTempTxtFile = lcSaveUrl && FORCEEXT(ADDBS(SYS(2023)) + SYS(2015), "TXT")

    Endif 

    lnGetResults = 0

    *-- lcGetURl = "http://moneycentral.msn.com/scripts/webquote.dll?iPage=qd&Symbol=" + ALLT(THISFORM.txtsymbol.VALUE);

     

     

    DECLARE LONG URLDownloadToFile IN URLMON.DLL LONG, STRING, STRING, LONG, LONG

     

    lnGetResults = URLDownloadToFile(0, lcGetURl, lcTempTxtFile, 0, 0)

    If lnGetResults # 0

    * MESSAGEBOX("Download Failed",0,ver)

    RETURN ""

    Endif

     

    *-- Read the Web page into a variable, and then erase it.

     

    Do Case 

    Case FileorStr = "STRING"

    lcrtn = FILETOSTR(lcTempTxtFile)

    ERASE (lcTempTxtFile)

    Case FileorStr = "FILE"

    lcrtn = lcTempTxtFile

    Endcase

    Return lcrtn

     

     


    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh 's Blog

    VFP Form to C#, Vb.Net Conversion Utility
    • Marked as answer by Andrew Mordi Thursday, January 26, 2012 3:00 AM
    Wednesday, January 25, 2012 6:50 AM
    Answerer

All replies

  • Hi Andrew

    you have Two Option

    1) Web Based SMS. SMS Provider Company provide you API to Send SMS using Internet Connection.

    2) GSM Modem. you can send SMS using AT Command via GSM Modem.

    Check below sample for AT Command 

    http://www.foxite.com/archives/how-can-i-send-sms-by-vfp6-0000066718.htm

    Regards

    Kalpesh


    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh 's Blog

    VFP Form to C#, Vb.Net Conversion Utility
    Friday, January 13, 2012 4:27 AM
    Answerer
  • Hi Kalpesh,

     

    Thanks a million. I got an API from my service provider to send SMS using Internet connection. It worked fine. The code I use is:

    URL=http://smsdam.com/http/?action=bulksms&username=myname&password=mypassword&message=Thank+you&mobile=2348033012091&sender=ANDREW"

    DECLARE INTEGER ShellExecute ;

    IN SHELL32.DLL ;

    INTEGER nWinHandle,;

    STRING cOperation,;

    STRING cFileName,;

    STRING cParameters,;

    STRING cDirectory,;

    INTEGER nShowWindow

    SHELLEXECUTE(0, "Open", URL, "", "", 1)

     

    *----------------------------------------

     

    The above code is in a command button (The phone number 2348033012091 is replaced by the actual customer's phone number in my application). On clicking the button, Internet Explorer is called up and the address bar is replaced by the URL above and executed, sending an SMS (Thank you) to the phone number.

     

    My new problem is: How can I get to execute the URL above without Opening an Internet Explorer Window? The Internet Explorer window is a nuisance because a new window is opened up whenever the button is clicked, which occurs whenever a new invoice is processed.

     

    Thanks once again.

     

    Andrew

    Tuesday, January 24, 2012 11:51 PM
  • Hi Andrew

    check below function to Execute your URL. there is three parameter 

    1) URL Name

    2) Result Required in STRING or FILE

    3) if Required File then  FILE Locaiton.

     

    Function ExecuteURL

    Lparameters lcgetUrl,FileOrStr,lcSaveUrl

     

    LOCAL lcQuote AS STRING,lcTempTxtFile AS STRING, lnGetResults AS INTEGER, lcURL AS STRING

    Local lcrtn

    lcQuote = ""

     

    *-- Set up a variable referring to a temp .TXT file.

    *-- Uses the current VFP TEMP DIR [SYS(2023)]

    *-- and a random file name [SYS(2015)]

    If Vartype(lcSaveURL)="L"

    lcTempTxtFile = FORCEEXT(ADDBS(SYS(2023)) + SYS(2015), "TXT")

    Else 

    lcTempTxtFile = lcSaveUrl && FORCEEXT(ADDBS(SYS(2023)) + SYS(2015), "TXT")

    Endif 

    lnGetResults = 0

    *-- lcGetURl = "http://moneycentral.msn.com/scripts/webquote.dll?iPage=qd&Symbol=" + ALLT(THISFORM.txtsymbol.VALUE);

     

     

    DECLARE LONG URLDownloadToFile IN URLMON.DLL LONG, STRING, STRING, LONG, LONG

     

    lnGetResults = URLDownloadToFile(0, lcGetURl, lcTempTxtFile, 0, 0)

    If lnGetResults # 0

    * MESSAGEBOX("Download Failed",0,ver)

    RETURN ""

    Endif

     

    *-- Read the Web page into a variable, and then erase it.

     

    Do Case 

    Case FileorStr = "STRING"

    lcrtn = FILETOSTR(lcTempTxtFile)

    ERASE (lcTempTxtFile)

    Case FileorStr = "FILE"

    lcrtn = lcTempTxtFile

    Endcase

    Return lcrtn

     

     


    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh 's Blog

    VFP Form to C#, Vb.Net Conversion Utility
    • Marked as answer by Andrew Mordi Thursday, January 26, 2012 3:00 AM
    Wednesday, January 25, 2012 6:50 AM
    Answerer
  • Kalpesh,

    I can't begin to explain how grateful I am. Your function worked great. I'm proud to be programming in Visual Foxpro.

    Andrew Mordi 

    • Proposed as answer by zienu Friday, July 12, 2013 12:59 PM
    • Unproposed as answer by zienu Friday, July 12, 2013 12:59 PM
    Thursday, January 26, 2012 2:59 AM
  • Hi,

    Can you please provide the complete code to send sms from VFP using  the URL

    v.abdulrahim@gmail.com

    Monday, July 08, 2013 8:08 AM
  • Hi Andrew,

    Thanks for your post, I am in same scenario, how do you finally build the code.

    Friday, July 12, 2013 1:01 PM
  • Zienu,

    Download the code from

    http://www.andrewmordi.com/sendsms.zip

    ......................

    Note the following

    a.   Phone Numbers are entered into PHONES.DBF

    b.   I got the API used from my SMS Provider. I had to customize the API string to accept my Username, Password and USERID that would display on the recipients’ phone

    c.   You are advised to break the phone number listing into batches of say 30 numbers each, in case you have thousands of phone numbers to send the SMS to.

    d.  The Function EXECUTEURL lives in the sms.prg and is invoked by a call in the SENDSMS Form.

    Andrew

    Monday, July 15, 2013 11:47 AM