NotifyScriptExecute - Plugin for Poptray
version 0.1 for Poptray by Enrico SchättinDescription
NotifyScriptExecute is a notification plugin for the very smart Poptray mail notifier. This plugin allows you to execute predefined windows script functions while poptray is checking your mails. So you will be able:
- to store the content of your mails to a directory on your hard drive,
- to start any program relating to the content and/or with the content of your mails
- to create and send a mail as an auto response to received mails automatically
- or anything you like to do with the information of the mail content ... it's on you and your ideas
You only need to know how to create Visual Basic Script or Java Script, so can develop functionalities in these languages to fill the plugin with life. But note that scripts executed by the plugin will be server side script execution. So it is not possible to use any user interaction in the scripts.
Requirements
All what you need is the Poptray mail notifier at least version 3.2. You can download it at www.poptray.org This plugin uses the Microsoft Windows Script Host to execute scripts. It is distributed and installed by default on Windows 98 and later versions of Microsoft Windows. By default it interprets and runs plain-text JScript (.JS files) and VBScript (.VBS files). So you don't need to install any additionals.
Download
Download the archive NotifyScriptExecute.zip and save it to your hard drive. Keep in mind where you saved it. For Installation you need a program to unpack the archive. How to unpack an archive you can find a description here, otherwise you can use WinZip, ExtractNow or UnZipper.
Installation
- Download the archive.
- Unpack it to the plugin directory of your Poptray installation.
- Close and restart PopTray.
- Go to the options window in PopTray and select the plugin settings and activate the plugin "Script Execution".
- Now the plugin should work, and you can fill out the scripts with life and functionality.
How does it work?
This plugin is reading two script files in the plugin directory
- NotfiyScriptExecute.vbs - contains VB-Script code
- NotfiyScriptExecute.js - contains Javascript code
In each script the plugin is looking for following functions and if it exists the plugin will call this function:
MessageCheck (MsgFrom, MsgTo, Subject, MsgTime, Viewed, New, Important, Spam)
would be called with following parameters each time poptray retrieves a mail and reads it header information.
- MsgFrom - contains the mail sender
- MsgTo - contains the mail receiver
- Subject - contains the mail subject
- MsgTime - contains the date time
- Viewed - is set to "1" when mail is already viewed, otherwise is set to "0"
- New - is set to "1" when mail is new, otherwise is set to "0"
- Important - is set to "1" when mail is signed as importent, otherwise is set to "0"
- Spam - is set to "1" when mail is signed as spam, otherwise is set to "0"
MessageBody (MsgFrom, MsgTo, Subject, MsgTime, Viewed, New, Important, Spam, Header, Body)
would be called with following parameters each time Poptray retrieves a mail and reads it content
- MsgFrom - contains the mail sender
- MsgTo - contains the mail receiver
- Subject - contains the mail subject
- MsgTime - contains the date time
- Viewed - is set to "1" when mail is already viewed, otherwise is set to "0"
- New - is set to "1" when mail is new, otherwise is set to "0"
- Important - is set to "1" when mail is signed as importent, otherwise is set to "0"
- Spam - is set to "1" when mail is signed as spam, otherwise is set to "0"
- Header - contains the raw header information of the mail
- Body - contains the full body of the mail (only if the option "Download Body while Checking" is switched on.)
NotifyAccount (AccountNo, AccountName, AccountColor, MailCount, UnviewedCount, NewCount, ResetTray)
would be called with following parameters each time poptray has finished to check mails on an account.
- AccountNo - Number of the account in your Poptray configuration
- AccountName - Name of the account in your Poptray configuration
- AccountColor - Color of the account in your Poptray configuration
- MailCount - Count of all mails of this account
- UnviewedCount - Count of unviewed mails of this account
- NewCount - Count of news mails of this account
- ResetTray - Reset the tray
Notify (MailCount,UnviewedCount,NewCount,ResetTray)
would be called with following parameters each time poptray has finished to check all mails on all accounts.
- MailCount - Count of all mails of all accounts
- UnviewedCount - Count of unviewed mails of all accounts
- NewCount - Count of new mails of all accounts
- ResetTray - Reset the tray
Samples or Templates
Here is a sample for Visual Basic Script and a sample for Java Script, in each sample are declared all possible functions, that would be called by the plugin. In the following samples each function does nothing. You can take these samples as templates to create your own script functionality.
NotifyScriptExecute.vbs
Function MessageCheck (MsgFrom, MsgTo, Subject, MsgTime, MsgViewed, MsgNew, Important, Spam) 'Do something with given information End Function Function MessageBody (MsgFrom, MsgTo, Subject, MsgTime, MsgViewed, MsgNew, Important, Spam, Header, Body) 'Do something with given information End Function Function NotifyAccount (AccountNo,AccountName,AccountColor,MailCount,UnviewedCount,NewCount,ResetTray) 'Do something with given information End Function Function Notify (MailCount,UnviewedCount,NewCount,ResetTray) 'Do something with given information End Function
NotifyScriptExecute.js
function MessageCheck (MsgFrom, MsgTo, Subject, MsgTime, Viewed, New, Important, Spam) { // Do something with given information } function MessageBody (MsgFrom, MsgTo, Subject, MsgTime, Viewed, New, Important, Spam, Header, Body) { // Do something with given information } function NotifyAccount (AccountNo,AccountName,AccountColor,MailCount,UnviewedCount,NewCount,ResetTray) { // Do something with given information } function Notify (MailCount,UnviewedCount,NewCount,ResetTray) { // Do something with given information }
More examples for Visual Basic Script
Below you can find a Visual Basic Script sample, that is tracing all function calls by the plugin.NotifyScriptExecute.vbs
Function TraceFunctionCall (FileName, FileText) Set FS = CreateObject("scripting.filesystemobject") strFile = FileName If Not FS.FileExists(strFile) Then FS.CreateTextFile(strFile) End If Set FS = Nothing Set FS = CreateObject("scripting.filesystemobject") Set schreibeDatei = FS.OpenTextFile(strFile, 8) schreibeDatei.writeline "" & Date & " " & Time & " " & FileText schreibeDatei.close 'Schließen der Datei Set schreibeDatei = nothing 'Objekt zerstören End Function Function MessageCheck (MsgFrom, MsgTo, Subject, MsgTime, MsgViewed, MsgNew, Important, Spam) TraceFunctionCall "Plugins\\NotifyScriptExecute.trc", "MessageCheck (" & MsgFrom & ", " & MsgTo & ", " & Subject & ", " & MsgTime & ", " & MsgViewed & ", " & MsgNew & ", " & Important & ", " & Spam & ")" End Function Function NotifyAccount (AccountNo,AccountName,AccountColor,MailCount,UnviewedCount,NewCount,ResetTray) TraceFunctionCall "Plugins\\NotifyScriptExecute.trc", "NotifyAccount (" & AccountNo & ", " & AccountName & ", " & AccountColor & ", " & MailCount & ", " & UnviewedCount & ", " & NewCount & ", " & ResetTray & ")" End Function Function Notify (MailCount,UnviewedCount,NewCount,ResetTray) TraceFunctionCall "Plugins\\NotifyScriptExecute.trc", "Notify (" & MailCount & ", " & UnviewedCount & ", " & NewCount & ", " & ResetTray & ")" End Function
Below you can find a Visual Basic Script sample, that is storing all mails to a defined directory on your harddrive.
NotifyScriptExecute.vbs
Function MessageSave (MsgFrom, MsgTo, Subject, MsgTime, MsgViewed, MsgNew, Important, Spam, Header, Body) Set FS = CreateObject("scripting.filesystemobject") DateTimeVal = "" If (MsgTime = "") Then DateTimeVal = Now Else DateTimeVal = MsgTime End If strDateTime = Mid(DateTimeVal, 7, 4) & Mid(DateTimeVal, 4, 2) & Mid(DateTimeVal, 1, 2) & Mid(DateTimeVal, 12, 2) & Mid(DateTimeVal, 15, 2) & Mid(DateTimeVal, 18, 2) strFile = "c:\\tmp\\msg_" & strDateTime & ".txt" If Not FS.FileExists(strFile) Then FS.CreateTextFile(strFile) End If Set FS = Nothing Set FS = CreateObject("scripting.filesystemobject") Set schreibeDatei = FS.OpenTextFile(strFile, 2) schreibeDatei.writeline Header schreibeDatei.writeline Body schreibeDatei.close 'Schließen der Datei Set schreibeDatei = nothing 'Objekt zerstören End Function Function MessageBody (MsgFrom, MsgTo, MsgSubject, MsgTime, MsgViewed, MsgNew, Important, Spam, Header, Body) { MessageSave MsgFrom, MsgTo, Subject, MsgTime, MsgViewed, MsgNew, Important, Spam, Header, Body End Function