Controlling auto-response.

This forum is for discussing Mailtraq's Scripting features. Get help with Mailtraq scripts, templates and external ActiveX scripting.

Controlling auto-response.

Postby marcw » Fri Feb 24th, 2012 11:26pm

Hi all!

Not been in here a while... a bit rusty on the old scripting, not having written any for a while.

I have a version of Jim's autoresponder script, where it reads the autoresponse text from a file (found in auto-<user>.txt, where <user> is the mailbox name).

I want to be able to turn this on and off just by changing the file (i.e. have the "automatically respond to emails" box checked, but have nothing happen if the auto-marc.txt file is empty.

What's the simplest way to test for an empty file?

Cheers,

Marc
Marc Wilson

Cleopatra Consultants Limited
User avatar
marcw
 
Posts: 42
Joined: Thu Dec 30th, 2004 10:05am
Location: Tarporley, Cheshire, UK

Re: Controlling auto-response.

Postby Malc » Sat Feb 25th, 2012 2:50pm

Speaking generally:

Code: Select all
handle := OpenFile( path )

path
Identifies the file to be opened by its filing system name. If no path is provided, the default location of \database is assumed

handle
An integer reference for subsequent references to the open file or nul if the file cannot be opened


Code: Select all
EOF()
Determines whether any data remains available in a file, i.e. whether the file pointer has reached beyond the last line of the specified file. EOF() operates on the file handle of a previously opened file and is normally used within a loop in conjunction with the Read() function to retrieve the contents of a text file.

Boolean := EOF( handle )

handle
The file identifier returned by a call to the OpenFile() function

Boolean
"FALSE" if there is more data to be read. "TRUE" if the end of the file has been reached


So something like:

Code: Select all
a := OpenFile("auto-marc.txt");
if(a = 0,
  result := "File does not exist. Do something",
  If(EOF(a),
    result := "File exists and is empty. Do something else",
    result := "File exists and isn't empty. Do a different thing"
    )
  );
CloseFile(a)


Any help?
User avatar
Malc
Expert User
 
Posts: 242
Joined: Thu Dec 30th, 2004 1:46am
Location: London^WSurrey^WEssex^WCambs^WLondon^WEssex^WLancs^WEssex

Re: Controlling auto-response.

Postby marcw » Sat Feb 25th, 2012 5:43pm

Yeah, that's the sort of thing I need.

I want to be able to have response messages turned on/off based on other things happening on the server, or even scheduled (like, every weekend).

The "other things" are largely governed by a scripting language I know better than Mailtraq's script, so that's where to build in the intelligence, I guess.

The alternative is to make the response file a schedule, with sections each with a start/end time, and that sounds like heavy going!

Thanks Malc.

*PS* If/when I get it working to my satisfaction, I'll post up the finished version here to be poked at by all. :)
Marc Wilson

Cleopatra Consultants Limited
User avatar
marcw
 
Posts: 42
Joined: Thu Dec 30th, 2004 10:05am
Location: Tarporley, Cheshire, UK

Re: Controlling auto-response.

Postby marcw » Thu May 17th, 2012 7:41pm

So, I've added the following:

If(auto_reply,
Do(
db := "auto-reply.dbq",
If(DBRecordExists(db, MAILBOX),
Do(
reply := DBRead(db, MAILBOX, "reply"),
If(WildcardMatch(reply, "NO"), auto_reply := "FALSE")
)
);

And in auto-reply.dbq there are entries like:

[marc]
reply=NO

But it's not working. Where am I going wrong?
Marc Wilson

Cleopatra Consultants Limited
User avatar
marcw
 
Posts: 42
Joined: Thu Dec 30th, 2004 10:05am
Location: Tarporley, Cheshire, UK


Return to Mailtraq Scripting

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron