Author |
Message |
Dominic Klein
Joined: 23 Nov 2001 Posts: 132
|
|
how do you write an email-watch job |
|
I want a job that runs when it receives an email from someone. It will detach the 2 attachments to some folders and then run an ms-dos batch file. The pseudo code is like this : if internet domain name like 'somecompany.co.uk' then detach file A to folder s:\folderA detach file B to folder s:\folderB Run an MS-DOS batch file. Please can you advise on how to go about this ?
|
|
Mon Jul 08, 2002 7:11 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: how do you write an email-watch job |
|
24x7 currently supports email job triggers that check and filter incoming messages by message subject and text. If the subject and text could be any you can specify asterisk for both the subject and the text in the job trigger properties. The asterisk would mean *ANY* subject and text. In the job script check the sender's email address and if it is from 'somecompany.co.uk' then do what you want to do. The address is available via @V"sender" macro-parameter. In the job script you can use InStr( "@V"sender"", "somecompany.co.uk", 1, found ) for such condition checking. Note that attachments of found messages are automatically saved in the TEMP directory. In the job script you will only need to move these files to s:\folderA and s:\folderB. If you setup the job for all messages, like I suggested and you get quite many messages you may need to do some some maintanence on the TEMP directory in order to remove unwanted attachments (For example do FileDeleteEx( "c:\\temp", count) Still, it is better to narrow the job email filter by specifying full or partial subject or message for incoming emails. Use asterisk as a wildcard to specify partial text. : I want a job that runs when it receives an email from someone. : It will detach the 2 attachments to some folders and then run an ms-dos batch : file. : The pseudo code is like this : if internet domain name like : 'somecompany.co.uk' then : detach file A to folder s:\folderA : detach file B to folder s:\folderB : Run an MS-DOS batch file. : Please can you advise on how to go about this ?
|
|
Mon Jul 08, 2002 9:00 am |
|
 |
Dominic Klein
Joined: 23 Nov 2001 Posts: 132
|
|
Re: how do you write an email-watch job |
|
thanks for that, but I'm a bit unsure how it works as there are only 2 commands to do with email - ie MailSend or MailSendWithAttachment - how do you start off by telling 24x7 to look at incoming mail ?
|
|
Mon Jul 08, 2002 9:15 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: how do you write an email-watch job |
|
You use "When certain email arrives" job schedule. That's it. : thanks for that, but I'm a bit unsure how it works as there are only 2 : commands to do with email - ie MailSend or MailSendWithAttachment - how do : you start off by telling 24x7 to look at incoming mail ?
|
|
Mon Jul 08, 2002 9:38 am |
|
 |
Dominic Klein
Joined: 23 Nov 2001 Posts: 132
|
|
Re: how do you write an email-watch job |
|
: You use "When certain email arrives" job schedule. That's it. Doh ! Thanks !
|
|
Mon Jul 08, 2002 9:41 am |
|
 |
Dominic Klein
Joined: 23 Nov 2001 Posts: 132
|
|
Re: how do you write an email-watch job |
|
I have written something but it doesn;t fire up - when I go thru the deugger the Sender is NULL ie "" why is this ? Dim(found, boolean) Dim(Sender, string) // check who has sent the email set Sender, "@V"sender"" Instr("@V"sender"","Dominic.Klein",1, found) // mail me the result IfThen( found, mail_result ) //exit MAIL_RESULT: MailSend( "NOVA", "password", "Dominic Klein", "it worked", "email arrived" )
|
|
Mon Jul 08, 2002 10:52 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: how do you write an email-watch job |
|
When you go though the debugger you trigger the job manually, there is no suitable message found and passed to the job by the automated job trigger and so there is no sender. If you open Outlook or other email client that you use, you should be able to see newly arrived messages in the Inbox turn their status to "read", in other words become marked as read. The job will fire only if the job trigger finds messages matching the specified subject and text. Just in case add asterisk to the end of the specified subject and message text because the real text may have some additional characters not seen on the screen but present in the message source (this may include spaces, tabs, end-of-line symbols, etc...) : I have written something but it doesn;t fire up - when I go thru the deugger : the Sender is NULL ie "" why is this ? : Dim(found, boolean) : Dim(Sender, string) : // check who has sent the email : set Sender, "@V"sender"" : Instr("@V"sender"","Dominic.Klein",1, found) : // mail me the result : IfThen( found, mail_result ) : //exit : MAIL_RESULT: MailSend( "NOVA", "password", "Dominic : Klein", "it worked", "email arrived" )
|
|
Mon Jul 08, 2002 11:28 am |
|
 |
Dominic Klein
Joined: 23 Nov 2001 Posts: 132
|
|
Re: how do you write an email-watch job |
|
I have got it to work on the master scheduler, but it does not work on the remote agent. Strangely enough if I enter the password for the mail box on either of the servers it doesn't have any effect, if I send the email to the MASTER server it works (even tho I tell the job to run on the remote agent) and it emails me. For some reason it is not triggering on the remote mailbox - only on the master
|
|
Mon Jul 08, 2002 11:45 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: how do you write an email-watch job |
|
The job should be setup on the computer where you have your email client configured for receiving incoming email messages. It should be the same as the master computer. If you don't have it on the master install and configure your email client program there. The job itself can run/be submited anywhere (not the job trigger, which runs where the job schedule is defined). : I have got it to work on the master scheduler, but it does not work on the : remote agent. Strangely enough if I enter the password for the mail box on : either of the servers it doesn't have any effect, if I send the email to : the MASTER server it works (even tho I tell the job to run on the remote : agent) and it emails me. : For some reason it is not triggering on the remote mailbox - only on the : master
|
|
Mon Jul 08, 2002 12:15 pm |
|
 |
Dominic Klein
Joined: 23 Nov 2001 Posts: 132
|
|
Re: how do you write an email-watch job |
|
OK, but I thought that you don't install jobs on Remote Agents - you just run the agent, not the scheduler on them because if you try and run the scheduler AND the agent on the same machine 24x7 throws up a warning message. I want to run the email trigger on the remote agent so that when an email is sent to the remote agent's mailbox it starts a job.
|
|
Mon Jul 08, 2002 1:51 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: how do you write an email-watch job |
|
Don't run 24x7 in the agent mode, run it in the master mode. You can still submit jobs from the first master and have your second master run some jobs localy. On other hand, the email is not sent to a computer, it is sent to an email account on your email server. The agent computer simply runs an email client program that is configured to access. The same way you can configure your master's computer email program to access the same account. Most email clients can be configured to access multiple accounts on the same or different email servers. : OK, but I thought that you don't install jobs on Remote Agents - you just run : the agent, not the scheduler on them because if you try and run the : scheduler AND the agent on the same machine 24x7 throws up a warning : message. : I want to run the email trigger on the remote agent so that when an email is : sent to the remote agent's mailbox it starts a job.
|
|
Mon Jul 08, 2002 2:02 pm |
|
 |
|