Ewon TechForum
Providing technical solutions to technical requests


XLSM Attachment with SENDMAIL
Lskadrille Offline
Junior Member
#1
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.


Attached Files
.png   attachment_txt.PNG (Size: 3,03 KB / Downloads: 1)
Reply

simon Offline
eWON Support
#2
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
Reply

Lskadrille Offline
Junior Member
#3
(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.
Reply



Possibly Related Threads…
05-03-2020, 01:25 PM
Last Post: ziozetti
28-06-2019, 03:23 PM
Last Post: Carl
21-12-2016, 02:12 AM
Last Post: AngelaT



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy