[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - scripts for templates

scripts for templates

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

scripts for templates

Postby MarkB » Tue Mar 13, 2012 2:55 am

A shortcut that starts a new message from a template
(whether or not Poco is running)

Method 1: The template is an .eml file. Create a shortcut to the Poco .exe file with a target similar to this:
"C:\Program Files (x86)\Pocomail4\Poco.exe" /edit "C:\Users\Mark\Desktop\MyTemplate.eml"

Method 2 (recommended): The template is a standard PocoMail template. The shortcut launches a script; the script opens the template.
Shortcut target, where OpenMyTemplate is the name of the script without the .poc extension:
"C:\Program Files (x86)\Pocomail4\Poco.exe" /r "OpenMyTemplate"
Script:
CommandTag "/perform/newmessage/MyTemplate/"

Thunderbird, for comparison:
"C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" -compose "to='Charles Dickens <cdickens@zzzzz.com>,Rex Stout <srex@yyyy.net>',subject='The latest BS',body='Hello,',attachment=file:///D:\test.rtf"

References:
http://www.bing.com/search?q=how+to+create+shortcuts
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Re: scripts for templates

Postby MarkB » Tue Mar 13, 2012 2:56 am

A SendTo menu item that starts a new message from a template and attaches selected files

User's procedure: Select a group of files, then right-click and select Send to | Harvey by email. A compose window will open (whether or not Poco is already running) with your defaults filled in and the selected files attached.

Code: Select all
{ SendFilesTo
{
{ A SendTo menu item that starts a new message from a template and attaches selected files
{
{ USAGE INSTRUCTIONS
{   Select a group of files, then right-click and select Send to | Harvey by email.
{   A compose window will open (whether or not Poco is already running) with
{   your defaults filled in and the selected files attached.
{
{ REQUIREMENTS
{   A fairly recent Windows OS on which Windows Scripting has not been disabled.
{   You may have to unhide "Hidden files and folders" in Folder Options in order to
{   see the SendTo folder.
{
{ SETUP
{   Each template requires its own set of 3 components: a Poco script, a VB script,
{   a shortcut in the SendTo folder.
{   1. Modify this script with your own template, under CreateMessage, and save it.
{   2. Run it. This creates the companion VBScript file in the Scripts folder, and
{   opens the Scripts and SendTo folders.
{   3. Right-drag the VBS file to the SendTo folder and choose "Create shortcuts
{   here." The SendTo folder in Vista/7 is here:
{   C:\Users\username\AppData\Roaming\Microsoft\Windows\SendTo
{   If you rename the Poco script, or modify the temp or VB script file name
{   variables, or change OSes, repeat Steps 2-3.
{
{ NOTES
{   The VB script receives the file names, makes them available to Poco scripts,
{   and launches this Poco script. The Poco script starts a new message, fills in
{   your defaults, and attaches the files.
{   AssignBody (plain text) works even when the compose window opens in Styled mode.
{   Original script by MarkB, 2010, 2012-03.

Set $OnErrorGoTo "ErrorHandler"

AddStrings $tempFileSpec $scriptpath $PocoScriptName "_yenralliKabotinaM_tmp.txt"
AddStrings $vbscriptFullName $PocoScriptName "_Vbs.vbs"
AddStrings $vbscriptFileSpec $scriptpath $vbscriptFullName

{ If the VB script does not yet exist, save it then quit.
FileExists &found $vbscriptFileSpec
If &found Then GotVbs
Goto SaveVbs
:GotVbs
{ If necessary, scold the user then quit.
FileExists &found $tempFileSpec
If &found Then GotTempFile
Set $t "Can't find the file\n"
AddStrings $t $tempFileSpec "\n\nUsage: Select files, right-click, choose Send to..."
MessageBox $t
Exit
:GotTempFile
{
{ Create a new message
{
CreateMessage %m
AddTo %m "Charles Dickens <chucky@zzzzzzzzz.com>"
AddTo %m "Rex Stout <wolfen@yyyyyyyyy.org>"
AddHeader %m "Subject:" "Love your stuff, guys"
Embed $body "EndEmbed"
G'day, Chuck and Rex.
Nothing new here.
Sincerely,
Joey
EndEmbed
AssignBody %m $body
{
{ Get contents of the temp file
{
OpenBody $a $tempFileSpec
TrimLines $a
DeleteFile $tempFileSpec
{
{ Attach files
{
LineCount #i $a
:AttachLoop
Dec #i
If #i < 0 Then ExitAttachLoop
GetLine $line #i $a
If $line = "" Then EndAttachLoop
FileExists &found $line
If &found Then GoodFile
Set $t "Error in PocoScript "
AddStrings $t $PocoScriptName "\nCan't find the file " $line
MessageBox $t
Goto EndAttachLoop
:GoodFile
AttachFile %m $line
:EndAttachLoop
Goto AttachLoop
:ExitAttachLoop
{
{ Edit, queue, or send the message
{
{    EDIT:  EditMessage %m
{
{    QUEUE:  SaveMessage %m "Out.mbx"
{
{    SEND:  SaveMessage %m "Out.mbx"
{           CommandTag "/menu/sendqueued"
{    (SendMessage is buggy.)
{
EditMessage %m

Exit









:SaveVbs
{ Create and save a VBScript file.

{
{ Notify the user
{
Set $t "Creating the file '"
AddStrings $t $vbscriptFullName "' in the PocoMail Scripts folder..."
MessageBox $t
{
{ Create the file
{
Set $pocoScriptFileSpec ""
AddStrings $pocoScriptFileSpec $scriptpath $PocoScriptName ".poc"
FileExists &found $pocoScriptFileSpec
If &found Then GotPocoScript
MessageBox "Aborting script. Really bizarre problem. No changes made on disk."
Exit
:GotPocoScript
Set $pocoexe $helppath
StringPos #i "Help" $pocoexe
ChopString $pocoexe #i 300
AddStrings $pocoexe "Poco.exe"
FileExists &found $pocoexe
If &found Then GotExe
MessageBox "Aborting script. Can't find the Poco executable. No changes made on disk."
Exit
:GotExe
Set $qm "\""
Set $code1 ""
AddStrings $code1 "Const PocoExe = " $qm $pocoexe $qm "\nConst TempFile = " $qm $tempFileSpec $qm "\nConst PocoscriptFile = " $qm $pocoScriptFileSpec $qm "\nConst PocoscriptName = " $qm $PocoScriptName $qm

Embed $code2 "EndEmbed"
qmark = Chr(34)

Const ForWriting = 2
Set objFilesys = CreateObject("Scripting.FileSystemObject")
With objFilesys
   If Not .FileExists(PocoExe) Then
      MsgBox "Can't find " & PocoExe, vbOKOnly + vbCritical, Wscript.ScriptName
   ElseIf Not .FileExists(PocoscriptFile) Then
      MsgBox "Can't find " & PocoScriptFile, vbOKOnly + vbCritical, Wscript.ScriptName
   ElseIf Not .FolderExists(.GetParentFolderName(TempFile)) Then
      MsgBox "Can't find " & .GetParentFolderName(TempFile), vbOKOnly + vbCritical, Wscript.ScriptName
   ElseIf .FileExists(TempFile) Then
      MsgBox TempFile & " already exists", vbOKOnly + vbCritical, Wscript.ScriptName
   Else
      Set MyFile = objFilesys.OpenTextFile(TempFile, ForWriting, True)
      For i = 0 To WScript.Arguments.Count - 1
         MyFile.WriteLine WScript.Arguments(i)
      Next
      MyFile.Close
      Set MyFile = Nothing
      Set wshShell = WScript.CreateObject("WSCript.shell")
      wshShell.Run qmark & PocoExe & qmark & " /r " & qmark & PocoscriptName & qmark
      Set wshShell = Nothing
   End If
End With
Set objFilesys = Nothing
EndEmbed

Set $code ""
AddStrings $code $code1 "\n" $code2
{
{ Save the file
{
AppendTofile False
SaveBody $code $vbscriptFileSpec
{
{ Open the Scripts and (if in Vista/7) the SendTo folders
{
Set $t "Please put a shortcut to this VBS file in your SendTo folder. The SendTo folder\n"
AddStrings $t "under Vista/7 is at \AppData\Roaming\Microsoft\Windows\SendTo."
MessageBox $t
Execute $scriptpath
Set $path $temppath
StringPos #i "Local" $path
ChopString $path #i 300
AddStrings $path "Roaming\Microsoft\Windows\SendTo"
Execute $path

Exit

:ErrorHandler
Set $t ""
AddStrings $t "Line " #ErrorLine " (Script \"" $PocoScriptName "\"):\n\n"
AddStrings $t $ErrorLine "\n\n"
AddStrings $t "Error: " $ErrorResult
MessageBox $t
Exit


Thunderbird version (brief), for comparison
Code: Select all
' SendFilesTo - Thunderbird
'
' A SendTo menu item that starts a new message from a template and attaches selected files
'
' USAGE INSTRUCTIONS
'   Select a group of files, then right-click and select Send to | Harvey by email.
'   A compose window will open (whether or not Tbird is already running) with
'   your defaults filled in and the selected files attached.
'
' REQUIREMENTS
'   A fairly recent Windows OS on which Windows Scripting has not been disabled.
'   You may have to unhide "Hidden files and folders" in Folder Options in order to
'   see the SendTo folder.
'
' SETUP
'   1. Modify this script with your own template and Thunderbird file spec.
'   2. Save the script in your SendTo folder, or save it somewhere else and put a
'   shortcut to it in the SendTo folder.
'
' NOTES
'   http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29
'
' MarkB, 2012.

Const template = "to='Charles Dickens <cdickens@zzzzz.com>,Rex Stout <srex@yyyy.net>',subject='The latest BS',body='Hi, guys.'"
Const TbirdExe = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
Dim i, max, qmark, filelist

qmark = Chr(34)
max = WScript.Arguments.Count - 1
For i = 0 To max
   filelist = filelist & WScript.Arguments(i)
   If i <> max Then filelist = filelist & ","
Next
WScript.CreateObject("WSCript.shell").Run qmark & TbirdExe & qmark & " /compose " & qmark & template & ",attachment='" & filelist & "'" & qmark
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 2 guests

cron