Desmond,

from my program I use to send email via blat the error you are getting back is "File name (message text) not given or Bad argument given":

Here is my full code in my EmailViaBlat.prg, maybe you can try it with your stuff and see if there is any difference:

LPARAMETERS tcReturn, tcFrom, tcTo, tcSubject, tcBody, taFiles, tcCC, tcBCC, tcMailServer, tnPort, tcUserName, tcPassword, tnPriority, tlHTMLFormat)
*******************************************
 LOCAL lcBlatParam, lcBodyFile, lnCountAttachments, lnResult, loError as Exception

m.lcBlatParam = m.lcBodyFile    &&GetShortPath(lcBodyFile)

 TRY
  *!* Include full path in Declare, such as "C:\Blat240\full\blat.dll"
  *!* or make sure that blat.dll is included in the system's PATH variable
  DECLARE INTEGER Send IN "blat.dll" STRING cParam
  lcBodyFile = ADDBS(SYS(2023)) + SYS(2015) + ".txt"
  STRTOFILE(tcBody, lcBodyFile, 0) && body is placed in a text file to be sent by BLAT

  lcBlatParam = GetShortPath(lcBodyFile)

  IF TYPE("tcTo") = "C"
    lcBlatParam = lcBlatParam + " -to " + ALLTRIM(tcTo)
  ENDIF
  IF TYPE("tcFrom") = "C"
    lcBlatParam = lcBlatParam + " -f " + ALLTRIM(tcFrom)
  ENDIF
  IF TYPE("tcCC") = "C"
    lcBlatParam = lcBlatParam + " -cc " + ALLTRIM(tcCC)
  ENDIF
  IF TYPE("tcBCC") = "C"
    lcBlatParam = lcBlatParam + " -bcc " + ALLTRIM(tcBCC)
  ENDIF
  IF TYPE("tcSubject") = "C"
    lcBlatParam = lcBlatParam + [ -s "] + ALLTRIM(tcSubject) + ["]
  ENDIF
  IF TYPE("tcMailserver") = "C"
    lcBlatParam = lcBlatParam + " -server " + ALLTRIM(tcMailserver)
  ENDIF
  IF TYPE("tnPort") = "N"
    lcBlatParam = lcBlatParam + ":" + TRANSFORM(tnPort)
  ENDIF
  IF TYPE("tcUsername") = "C"
    lcBlatParam = lcBlatParam + " -u " + ALLTRIM(tcUsername)
  ENDIF
  IF TYPE("tcPassword") = "C"
    lcBlatParam = lcBlatParam + " -pw " + ALLTRIM(tcPassword)
  ENDIF
  IF TYPE("tnPriority") = "N" AND BETWEEN(tnPriority, 0, 1)
    lcBlatParam = lcBlatParam + " -priority " + TRANSFORM(tnPriority)
  ENDIF
  IF TYPE("tlHTMLFormat") = "L" AND tlHTMLFormat
    lcBlatParam = lcBlatParam + " -html"
  ENDIF

  IF TYPE("taFiles", 1) = "A"
    lcBlatParam = lcBlatParam + " -attach "
   FOR lnCountAttachments = 1 TO ALEN(taFiles)
     lcBlatParam = lcBlatParam + '"' + GetShortPath(ALLTRIM(taFiles(lnCountAttachments))) + '",'
   ENDFOR
   lcBlatParam = LEFT(lcBlatParam, LEN(lcBlatParam) - 1) && Remove Extra Comma
  ENDIF

  lnResult = Send(ALLTRIM(m.lcBlatParam) + IIF(oAppinfo.BlatLog, " -log blat.log -debug", ""))

  IF lnResult != 0
   DO CASE
    CASE lnResult = -2
     THROW "The server actively denied our connection./The mail server doesn't like the sender name. "
    CASE lnResult = -1
     THROW "Unable to open SMTP socket or SMTP get line did not return 220 or command unable to write to socket or Server does not like To: address or Mail server error accepting message data."
    CASE lnResult = 1
     THROW "File name (message text) not given or Bad argument given"
    CASE lnResult = 2
     THROW "File (message text) does not exist"
    CASE lnResult = 3
     THROW "Error reading the file (message text) or attached file"
    CASE lnResult = 4
     THROW "File (message text) not of type FILE_TYPE_DISK "
    CASE lnResult = 5
     THROW "Error Reading File (message text)"
    CASE lnResult = 12
     THROW "-server or -f options not specified and not found in registry"
    CASE lnResult = 13
     THROW "Error opening temporary file in temp directory"
    OTHERWISE
     THROW "Unknown Error"
   ENDCASE
  ENDIF

 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 "Send"
  IF FILE(lcBodyFile)
   ERASE (lcBodyFile)
  ENDIF
 ENDTRY
*!*    ENDPROC

****************************************
Function GetShortPath
****************************************
 LPARAMETERS lcFileName
 LOCAL lnReturn, lcBuffer

 Declare Integer GetShortPathNameA In Win32API As GetShortPathName String, String, Integer

 lcBuffer = SPACE(255)
 lnReturn= GetShortPathName(lcFileName, @lcBuffer, 255)

 Clear Dlls "GetShortPathName"

 Return (Left(lcBuffer, lnReturn))
ENDFUNC

Frank.

Frank Cazabon

On 28/06/2018 01:31 PM, Desmond Lloyd wrote:
Good Morning all,

Have been using Blat here at work for years.   Essentially modifying the
code as the need arose.  now have a client that I would like to use it on,
but for some reason it always returns a code 1 in the new environment but
works fine here at work...

Would someone please look at the sample below to see what I might be
missing?

LPARAMETERS lcsubject, lcbody, lcrecipient, lcfrom, lccopyto

lcFrom = '[email protected]'

*lcfrom = '[email protected]'

lcSubject = 'Email Test'

set Safety off

lcBody = 'This is a Test of an automated email system. Third Test. Would
you Please reply if received'+ CHR(13) + CHR(10) + CHR(13) + CHR(10)

lcRecipient = '[email protected]'

STRTOFILE(lcbody, "Body.txt")

lcstring = 'C:\Body.txt -s "' + lcsubject + '" -to ' + lcrecipient + ' -f '
+ lcfrom + ' -u '+'dlloyd'+' -pw '+'password'+ ' -server '+'192.168.999..62'

dll_name = "blat.dll"

DECLARE INTEGER Send in &dll_name STRING blatstring

lnresult = send(lcstring)

IF lnresult > 0

wait window 'Result: '+alltrim(str(lnREsult))

ENDIF


--- StripMime Report -- processed MIME parts ---
multipart/alternative
   text/plain (text body -- kept)
   text/html
---

[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to