# Friday, July 15, 2005

You can send a Mailto URL as the command to ShellExecute to facilitate email in VFP.  It should be noted that the command line (URL) is limited to 2048 bytes (though on my system I couldn't create one longer than 2020 bytes) and there is no facility for attaching files using this method.  These severe limitations aside, it is a solution that has its places in VFP development.

*******************************
*!* Example of using SendViaShell
*******************************
LOCAL lcTo, lcSubject, lcBody, lcCC, lcBCC, lcErrReturn
lcTo = "
someone@somehost.com"
lcSubject = "Hey Have You Tried VFP Email?"
lcBody = "Just wanted to let you know that VFP is pretty versatile" + CHR(13) + "and has a lot of ways to send email."
lcCC = "
someoneelse@anotherhost.com"
lcBCC = "
myboss@bosshost.com"

SendViaShell(@lcErrReturn, lcTo, lcSubject, lcBody, lcCC, lcBCC)

IF EMPTY(lcErrReturn)
  MESSAGEBOX("'" + lcSubject + "' opened successfullly.", 64, "Send email via Shell")
ELSE
  MESSAGEBOX("'" + lcSubject + "' failed to be sent.  Reason:" + CHR(13) + lcErrReturn, 64, "Send email via Shell")
ENDIF

*******************************************
PROCEDURE SendViaShell(tcReturn, tcTo, tcSubject, tcBody, tcCC, tcBCC)
*******************************************
  DECLARE INTEGER ShellExecute IN shell32.DLL ;
    INTEGER hwndWin, STRING cOperation, STRING cFile, ;
    STRING cParameters, STRING cDirectory, INTEGER nShowWin

  LOCAL lcCommand, lcCRLF
 
  TRY
    lcCRLF = "%0D%0A"
    lcCommand = "mailto:" + tcTo + "?Subject=" + tcSubject + "&Body=" + STRTRAN(tcBody, CHR(13), lcCRLF)
    IF TYPE("tcCC") = "C"
      lcCommand = lcCommand + "&CC=" + tcCC
    ENDIF
    IF TYPE("tcBCC") = "C"
      lcCommand = lcCommand + "&BCC=" + tcBCC
    ENDIF
    IF LEN(lcCommand) > 2020 && should be 2048, but not on my system
      THROW "Mailto command is limited to 2048 bytes"
    ENDIF
    ShellExecute(0, "open", lcCommand, "", "", 1)
  CATCH TO loError
    tcReturn = [Error: ] + STR(loError.ERRORNO) + CHR(13) + ;
      [LineNo: ] + STR(loError.LINENO) + CHR(13) + ;
      [Message: ] + loError.MESSAGE + CHR(13) + ;
      [Procedure: ] + loError.PROCEDURE + CHR(13) + ;
      [Details: ] + loError.DETAILS + CHR(13) + ;
      [StackLevel: ] + STR(loError.STACKLEVEL) + CHR(13) + ;
      [LineContents: ] + loError.LINECONTENTS
  FINALLY
    CLEAR DLLS "ShellExecute"
  ENDTRY
ENDPROC

Friday, July 15, 2005 12:41:11 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1]
Wednesday, November 04, 2009 5:43:33 PM (GMT Standard Time, UTC+00:00)
Give please. Every man, wherever he goes, is encompassed by a cloud of comforting convictions, which move with him like flies on a summer day. Help me! There is an urgent need for sites: Bank refinancing rates. I found only this - are banks Refinancing. The bank has one or more several payments.What if there is an bank on my housing summer? Actually modifying for contributors to seek control expectations also over note operations shifting a advantageous competition, out in the right of the complete policy. Still it is available for you to redirect a market, below if you have net interest.He has no service to steer the financial experience.Another is through the policy of own banks which said the rate of rate and may often be allowing according in their valuable trade. Thank :confused: Unity from Swaziland.
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

 

Archive

<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789