LUA Email Script Help

You can share your Lua Scripts with everybody here.
Post Reply
tmays
Posts: 4
Joined: Fri Jun 15, 2012 3:59 pm

LUA Email Script Help

Post 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
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: LUA Email Script Help

Post by FTP »

Code: Select all

local fp = assert(io.open("c:/email.txt", "rb"))
local content = fp:read("*all")
fp:close()
tmays
Posts: 4
Joined: Fri Jun 15, 2012 3:59 pm

Re: LUA Email Script Help

Post 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.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: LUA Email Script Help

Post 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")
Post Reply