Switch to desktop version  
XLSM Attachment with SENDMAIL - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html)
+--- Thread: XLSM Attachment with SENDMAIL (/thread-1113.html)



XLSM Attachment with SENDMAIL - Lskadrille - 02-12-2019

Hi,

I try to send a mail with a remane excel File on a TAG trigger in a PLC.

It's work, I rename the file, Send the mail but it become a ".txt" file.

Attachment like : "$dtUF$uf_usr_NEXTALIM_BATCH_01.xlsm$ftT.txt".

It's possible to do this or it's only bin file or txt file as attachment ?

Code:
Rem --- eWON start section: Cyclic Section
eWON_cyclic_section:
Rem --- eWON user (start)
IF GETIO "DATA_02" = 1 AND myVar = 0 THEN
  PRINT "If ok -> MyVar => 1"
  myIndex% = myIndex% + 1
  FullPath$ = "/usr/NEXTALIM_BATCH_" + SFMT myIndex%,30,0,"%002d" + ".xlsm"
 
  myACTIONSTAT = FS "cp","/usr/NEXTALIM_BATCH.xlsm",FullPath$
  PRINT "request actionstat is "; myACTIONSTAT
 
  SENDMAIL "xxxxxxxxxx@yyyyyyyyy.be","","Rapport Hygiénisation : " + FullPath$,"&[$dtUF$uf" + FullPath$ + "$ftT]"
  myIDSENDMAIL = GETSYS PRG, "ACTIONID"
 
  TestAgain:
 
  myACTIONSTAT = GETSYS PRG, "ACTIONSTAT"
 
  if myACTIONSTAT = -1 THEN
    GOTO TestAgain
  ENDIF
 
  PRINT "request actionstat is "; myACTIONSTAT
 
  myVar = 1
ENDIF

IF GETIO "DATA_02" = 0 AND myVar = 1 THEN
  PRINT "If ok -> MyVar => 0"
  ERASE FullPath$
  myVar = 0
ENDIF

Rem --- eWON user (end)
End
Rem --- eWON end section: Cyclic Section
Rem --- eWON start section: Init Section
eWON_init_section:
Rem --- eWON user (start)
myVar = 0
myIDSENDMAIL = 0
myACTIONSTAT = 0
myIndex% = 0
FullPath$ = ""
Rem --- eWON user (end)
End
Rem --- eWON end section: Init Section

Best regards.


RE: XLSM Attachment with SENDMAIL - simon - 03-12-2019

Hi,

You should simply remove the $ftT.txt from the Export Bloc Descriptor. You can use $fn to specify another name to your file ($fnTest.xls)

Also, we do not recommend to use the cyclic section to make such a thing.
I would better recommend you use the event ONCHAGE Tagname, "GOTO SENDMYMAIL" that you simply put in the init.
This will trigger the script "GOTO SENDMYMAIL" wheneven the tag "Tagname" changes.

Simon


RE: XLSM Attachment with SENDMAIL - Lskadrille - 05-12-2019

(03-12-2019, 04:49 PM)simon Wrote: Hi,

You should simply remove the $ftT.txt from the Export Bloc Descriptor.  You can use $fn to specify another name to your file ($fnTest.xls)

Also, we do not recommend to use the cyclic section to make such a thing.
I would better recommend you use the event ONCHAGE Tagname, "GOTO SENDMYMAIL" that you simply put in the init.
This will trigger the script "GOTO SENDMYMAIL" wheneven the tag "Tagname" changes.

Simon

Hi,

Thank you Simon. It's work !

I will apply your recommendation.

Regards.