Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Run script on new e-mails

Posted on 2003-12-02
13
Medium Priority
?
416 Views
Last Modified: 2013-12-18
Hi All,

I'm currently working on a project where the client uses wintel boxes using lotus notes. Coming from a unix background I am used to the delightful flexibility of procmail and shell scripting. I would like to use a similar method with Notes but I'm not sure where to look - can anyone tell me how you can run scripts (Lotus script??) on incoming mails?

i.e: is it possible to create a "rule" for new mails similar to the following pseudo code:

  If ("mail subject" = "some text" and "hasAttachment" = True) {
    Run a dos command on the mails attachment
  }

Note: Notes R5 on W2k pro

Thanks,

Haydn.
 
0
Comment
Question by:HaydnH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 19

Expert Comment

by:madheeswar
ID: 9856936
U need to write an agent and the condition should be When New mail arrives.

What is ur exact requiremnt?
0
 
LVL 8

Author Comment

by:HaydnH
ID: 9857290
"U need to write an agent and the condition should be When New mail arrives"

How is this done? Where in Notes is it and what language is it written in?


"What is ur exact requiremnt?"

Basically I'm lazy - which is why I love programming =P

I get sent spreadsheets monthly (about 15 of them from different managers), I currently have a form in an access database which allows me to bundle all of the spreadsheets together, update the database from them and generate another spreadhsheet from the updated data in the database.

All of this could be run through a macro (currently run from vba) and as such I can run it from a command line ("msacces mydb.dbm /x mymacro").

What I wish to do is stop having to waste time going through the 15 spreadhseets and telling the database where they are... so I would like a script (agent??) in notes that:

    When new mail arrives...
                  |
                  |                                             |No
    Does it have the subject "My Subject"?  ------- Leave in InBox
                  |
                  |---- Yes
                  |
    Does it have an xls attachment? --------------- Mark as error (possibly mail manager)
                  |
                  |
    Save attachment to c:\somewhere\somefile.xls
    And run command line (as above)
                  |
                  |
    Move mail to completed folder


Haydn.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9863236
The process would have to run in teh same place you have the mail file.  Usually, mail files stay on the Domino server (Notes server).  But you probably DON'T want to put the file shares and teh other executable on the Domino server.  All kinds of security and performance issues with that.  If that isn't a concern, I can show you the simplest way to accomplish it.  If you are nervous (as I would be) about placing the sahres and executables on teh Domino server, I'll discuss a more complex solution with you.

Anyway, here's the "simple" version that runs on teh Domino server.

Install Designer f you don't already have it installed
Open mail file
Create -> Agent
Set to run before new mail arrives
Change from SIMPLE ACTION to LOTUSSCRIPT
Click on the INITIALIZE "event"
Here's your code:

CONST SubjectText = "My subject" 'must be an exact match, no leading or trailing characters, not even extra spaces
CONST ExtractPath = "c:\somewhere\somefile.xls" 'include path and file name
CONST commandLine = "c:\someplace\someprogram.exe"

Dim s as new notesSession
Dim db as notesDatabase
Set db = s.currentDatabase
Dim messages as notesDocumentCollection
Set messages = db.unprocessedDocuments
Dim msg as notesDocument, nextMsg as notesDocument
Set msg = messages.getFirstDOcument
Do Until msg is nothing
  Set nextMsg = messages.getNextMessage(ms) 'cache the next one in case we lose track of position due to a delete
  If msg.Subject(0) = SubjectText Then
    Dim xlsCheck
    xlsCheck = Evaluate({!""=@Trim(@Left(@UpperCase(@AttachmentNames);".XLS"))},msg)
    If xlsCheck(0) = "0"
      msg.Subject = "***MISSING EXCEL FILE***" & doc.Subject(0)
    Else
      Dim fileName
      fileName = Evaluate({@Trim(@Left(@UpperCase(@AttachmentNames);".XLS"))},msg)
      Dim attachment as notesEmbeddedObject
      Set attachment = doc.getAttachment(fileName(0))
      If attachment is nothing Then
        msg.Subject = "***COULD NOT RETRIEVE EXCEL FILE***" & doc.Subject(0)
      Else
        attachment.extractFile ExtractPath
        Dim shellReturn as Long
        shellReturn = SHell(commandLine)
        msg.moveToFlder "Completed"
      End If
    End If
  End If
  Set msg = nextMsg 'retrieve from cache
Loop
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 31

Expert Comment

by:qwaletee
ID: 9863258
Oops!  typos alert

    If xlsCheck(0) = "0" ->     If xlsCheck(0) = "0" Then


            Set nextMsg = messages.getNextMessage(ms) 'cache the next one in case we lose track of position due to a delete
->               Set nextMsg = messages.getNextDocument(msg) 'cache the next one in case we lose track of position due to a delete

                        msg.Subject = "***MISSING EXCEL FILE***" & doc.Subject(0)
->                          msg.Subject = "***MISSING EXCEL FILE***" & msg.Subject(0)

                        Set attachment = doc.getAttachment(fileName(0))
->                          Set attachment = msg.getAttachment(fileName(0))


                              msg.Subject = "***COULD NOT RETRIEVE EXCEL FILE***" & doc.Subject(0)
->                                msg.Subject = "***COULD NOT RETRIEVE EXCEL FILE***" & msg.Subject(0)

        msg.moveToFlder "Completed" ->         msg.moveToFolder "Completed"

0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9863261
WIth above corrections incorporated:
      Const SubjectText = "My subject" 'must be an exact match, no leading or trailing characters, not even extra spaces
      Const ExtractPath = "c:\somewhere\somefile.xls" 'include path and file name
      Const commandLine = "c:\someplace\someprogram.exe"
      
      Dim s As New notesSession
      Dim db As notesDatabase
      Set db = s.currentDatabase
      Dim messages As notesDocumentCollection
      Set messages = db.unprocessedDocuments
      Dim msg As notesDocument, nextMsg As notesDocument
      Set msg = messages.getFirstDOcument
      Do Until msg Is Nothing
            Set nextMsg = messages.getNextDocument(msg) 'cache the next one in case we lose track of position due to a delete
            If msg.Subject(0) = SubjectText Then
                  Dim xlsCheck
                  xlsCheck = Evaluate({!""=@Trim(@Left(@UpperCase(@AttachmentNames);".XLS"))},msg)
                  If xlsCheck(0) = "0" Then
                        msg.Subject = "***MISSING EXCEL FILE***" & msg.Subject(0)
                  Else
                        Dim fileName
                        fileName = Evaluate({@Trim(@Left(@UpperCase(@AttachmentNames);".XLS"))},msg)
                        Dim attachment As notesEmbeddedObject
                        Set attachment = msg.getAttachment(fileName(0))
                        If attachment Is Nothing Then
                              msg.Subject = "***COULD NOT RETRIEVE EXCEL FILE***" & msg.Subject(0)
                        Else
                              attachment.extractFile ExtractPath
                              Dim shellReturn As Long
                              shellReturn = Shell(commandLine)
                              msg.moveToFolder "Completed"
                        End If
                  End If
            End If
            Set msg = nextMsg 'retrieve from cache
      Loop
0
 
LVL 8

Author Comment

by:HaydnH
ID: 9865103
OK... I'm working in a council office for this project, and as such the IT dept are a little 'protective' about their servers (read: they don't want any extra work!), so:

 - The script has to be run on the workstation when reading mail - not the server
      ... because I can't access the servers
      ... and the script will have to run on a machine with access installed

 - We don't have designer and I assume it cost's $$$ - the council has no budget for me!

Is this still possible? If not I'm beginning to hate notes more and more each day!

Haydn.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9865128
all the mails coming in to inbox are on server.

if u want to run agent on incoming emails means, u have to keep that agent on server.

Locally if u replicate also, the document is already in the inbox on server database.

So, as I think it is not possible without altering template. U have to adjust like that.

0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9865145
and without extra work it is not possible. even they can't spend money for any 3rd party softwares.

If u want to achieve some thing, u have to choose any of the above options.

Spend money or allot some time to do extra work.

For designer u need to spend money. And u need one designer to implement it.

One more time I am telling:
To run on incomng emails which are coming from server, u need to run agent on the server.

Else:
Qwaletee:
Can we run that agent from any other application to look into inbox of the person and when it came, then do the necessary things?
What do u say Qwaletee?

A lost hope is to run agent from another database. For this also, u need designer.
0
 
LVL 8

Author Comment

by:HaydnH
ID: 9865699
hmmm... can I access a notes server using any other mail client? i.e: does the server support POP3/IMAP?
0
 
LVL 5

Expert Comment

by:Goofytouy
ID: 9866870
haydnH

The Domino family servers support POP3/IMAP, but they must be enabled (subapp running).
You may speak to your IT dept and ask if the domino server is reachable with programs like Outlook.



0
 
LVL 19

Accepted Solution

by:
madheeswar earned 750 total points
ID: 9871285
load smtp is the command which u have to type at server console. This will enable POP3

But, u have to know the pros and cons once u enable this.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9872141
Ah, madheeswar, that should be:

LOAD POP3 to enable POP3
OAD IMAP to enable IMAP4
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 750 total points
ID: 9872155
HaydnH,
> hmmm... can I access a notes server using any other mail client? i.e: does
> the server support POP3/IMAP?

You can run the agent locally by making a local replica.  As I mentioned, it would have to be set to "new documents" instead of "when mail is delievered."  There really would not be much difference in the way it performs, and the code would be identical.

You can also have Access do the scripting.  The Notes object model is available via COM.  So, most of that script could go straight into VBA.  It could access the server data, whiel executing teh code on a workstation.

If you want to create agents (native Notes processing), you would definitely need Designer.  Only very basic agents are supported without Designer.  You can doanload the Designer trial from notes.net.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

609 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