[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

When New Mail Arrives In Lotus If Subject Contains A Specific Phrase Execute A File On The Network

Posted on 2007-08-10
7
Medium Priority
?
299 Views
Last Modified: 2013-12-18
Hello all, hopefully this is easy to understand.  What I would really like to do is setup an agent (if that is the approriate method) to do something if a email that comes to me has a specific phrase in the subject line.  If the phrase is a specific phrase as specified in the agent I want to execute a file on the network.  Watcha think?  Can it be done?  I am looking for some code examples to do this!  Thanks in advance.
0
Comment
Question by:jwebster77
  • 3
  • 2
  • 2
7 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 19671805
It can be done, the question is how best to do this.

I would set up a rule that puts the mail in a specific folder, and then run an agent  every 5 minutes, and check for an email in th folder, run your code, and move the doc out of that folder ad into some other folder.

I hope this helps !
0
 
LVL 63

Accepted Solution

by:
SysExpert earned 1000 total points
ID: 19671827
Use the shell command to run a progam

The following example is specific to Windows:
' Start the Windows Calculator as a normal (not minimized)
' window with focus.
Dim result As Integer
result = Shell("CALC.EXE",

-----

Syntax
Shell ( program [ , windowStyle ] )
Elements
program
A string expression whose value is the name of the program to run, including arguments. program can be the name of an executable file that uses a file name extension of BAT, COM, PIF, or EXE. You can omit the file name extension, and you can optionally include a complete path specification.
Using an internal DOS command name generates an error.
windowStyle
Optional. A number designating a valid window style, as specified in the following table.
Style      Description      Constant
1, 5, or 9      Normal with focus      SHELL_NORMAL_FOCUS
2       Minimized with focus (default)      SHELL_MIN_FOCUS
3       Maximized with focus      SHELL_MAX_FOCUS
4 or 8      Normal without focus      SHELL_NORMAL_NO_FOCUS
6 or 7      Minimized without focus      SHELL_MIN_NO_FOCUS
The constants are defined in the file lsconst.lss. Including this file in your script allows you to use constant names instead of the numeric values assigned to them.
Return value
If LotusScript successfully starts program, Shell returns the number 33.
Note  To get the program's task ID, use the Shellid function instead.
If LotusScript cannot start program, Shell returns an error.
Usage
Shell must be called from within an expression or an assignment statement, so that its return value is used.
In a UNIX or AIX environment, LotusScript will resume execution of the script only after the program has completed.  
In other environments, after Shell starts a program, LotusScript continues to execute the script without waiting to make sure the program has completed. You cannot be sure that a program started by Shell has finished running before the rest of your script is executed.
Language cross-reference

--------------

I hope this helps !
0
 

Author Comment

by:jwebster77
ID: 19672374
I have this in my agent...  See the part below where the ----- are because that is where the action happens for what I want to do here.  Is the syntax right  I'm thinking maybe reading the subject line is incorrect

Sub Initialize
      Const sForward = "myblackberryaddress"
      
      Dim session As New NotesSession
      Dim note As NotesDocument
      Dim docNew As Notesdocument
      Dim db As NotesDatabase
      Dim item As NotesItem
      
      Set session = New NotesSession
      Set db = session.CurrentDatabase
      Set note = session.DocumentContext
      Set item = note.GetFirstItem("Body")
      
      Set docNew = New Notesdocument(db)
      docNew.Form = "Memo"
      Call item.copyitemtodocument(docNew, "")
      docNew.SendTo = sForward
      docNew.From = " " & note.From(0)
      docNew.Principal = " " & note.From(0)
      docNew.Subject = note.Subject(0)
      
      Call docNew.Send(True)
      
      If note.subject(0) = "REBOOT" Then
            Dim result As Integer
            result = Shell("\\AdminPC\OracleApps3Restart\OracleApps3Restart.bat",1)
      End If
      
End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jwebster77
ID: 19672419
I have this in my agent...  See the part below where the ----- are because that is where the action happens for what I want to do here.  Is the syntax right  I'm thinking maybe reading the subject line is incorrect

Sub Initialize
      Const sForward = "myblackberryaddress"
     
      Dim session As New NotesSession
      Dim note As NotesDocument
      Dim docNew As Notesdocument
      Dim db As NotesDatabase
      Dim item As NotesItem
     
      Set session = New NotesSession
      Set db = session.CurrentDatabase
      Set note = session.DocumentContext
      Set item = note.GetFirstItem("Body")
     
      Set docNew = New Notesdocument(db)
      docNew.Form = "Memo"
      Call item.copyitemtodocument(docNew, "")
      docNew.SendTo = sForward
      docNew.From = " " & note.From(0)
      docNew.Principal = " " & note.From(0)
      docNew.Subject = note.Subject(0)
     
      Call docNew.Send(True)
      ------
      If note.subject(0) = "REBOOT" Then
            Dim result As Integer
            result = Shell("\\AdminPC\OracleApps3Restart\OracleApps3Restart.bat",1)
      End If
     
End Sub
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 19672562
Code won't do what you want it to.  This doesn't say "tell the PC named AdminPC to run a file it has named oracle3appsrestart.bat."

What it does mean is "go retrueve the file oracleapps3restart.bat," and run that file on the computer that is running the agent.

To do what you want, you need to get a program that executes other programs remotely.  Mark Russinovich's PsTools suite includes a utility to do this.  Microsoft bought his company, so these are now Microsoft-provided free tools.

As to your search code, why bother? Set a agent to process new messages, create a condition on your agent taht matches the subject phrase, and your code will be as simple as:

Sub Initialize
   x = Shell("C:\Program Files\PsTools\PsExec \\AdminPC C:\OracleApps3Restart\OracleApps3restart.bat")
End Sub
0
 

Author Comment

by:jwebster77
ID: 19673052
I guess my questions becomes, how do I create a condition on an agent.  I agree, taht woudl be the easy way.
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 1000 total points
ID: 19673907
1) Full text index the database

2) In the agent screen click on DOCUMENT SELECTION

3) Click ADD CONDITION

4) Choose condition BY FIELD

5) Select field SUBJECT

6) Enter the phrase you are seartching for in "value"
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question