Page 1 of 1

LUA Email Script Help

Posted: Fri Jun 15, 2012 4:06 pm
by tmays
I am working on adding the LUA scripts on fileuploaded events. So far I have this code working:

Code: Select all

if string.find("%PathName","Testing/") then
c_SendMail("tmays@test.com","%FileName has been uploaded","%Name uploaded into %PathName","email.txt","Exchange")
c_SendMail("mays.tj@test.com","A File Posting Notification","Your file %FileName is available for retrieval.","","Exchange")
end
But what I am wanting to do is for the body of the email is to be able to have the script read from a text file instead of having to write the entire content in the code.

For example.
c_SendMail("tmays@test.com","%FileName has been uploaded","readfrom("email.txt"),"Exchange")

Can someone help?


-TJ

Re: LUA Email Script Help

Posted: Mon Jun 18, 2012 7:47 am
by FTP

Code: Select all

local fp = assert(io.open("c:/email.txt", "rb"))
local content = fp:read("*all")
fp:close()

Re: LUA Email Script Help

Posted: Mon Jun 18, 2012 12:47 pm
by tmays
Thanks,

Does this code need to be inserted in the line of code or at the start of the script? Sorry very new to LUA Scripts.

Re: LUA Email Script Help

Posted: Mon Jun 18, 2012 2:04 pm
by FTP

Code: Select all

local fp = assert(io.open("c:/email.txt", "rb"))
local content = fp:read("*all")
fp:close()

c_SendMail("mays.tj@test.com","A File Posting Notification",content,"","Exchange")