[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 - SaveAllToEML.poc - save messages to eml files

SaveAllToEML.poc - save messages to eml files

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

SaveAllToEML.poc - save messages to eml files

Postby Tomas » Sun Apr 12, 2009 6:55 am

Code: Select all
{ Script Name   :   SaveAllToEML.poc
{ Authors       :   Tomas http://www.pocosystems.com/forum/profile.php?mode=viewprofile&u=9
{ Creation Date :   2009.04.12
{ Version       :   1.0
{ Usage         :   no restrictions
{ Description   :   This script will save message to .eml file. It handles
{ forbidden Windows filename characters. Duplicate handling section was abandoned, I believe Poco UID
{ is unique enough for that not to be necessary, anyway chances are it's not 100% safe but only 99,999% safe
{ thus that's a chance for future improvement.
{ Revision History
{ ----------------
{ YYYY.MM.DD    Developer       Notes
{ ----------    --------------- -------------------------------
{
{}

Set $filepath $apppath
Set $filename ""
Set $extension ".eml"
{just to be a bit safer, set appendtofile}
AppendToFile True

ReadHeader $subject "Subject:" %message
ReadHeader $uid "X-Poco-UID:" %message

AddStrings $filename $subject "-" $uid $extension
ReplaceNBSP $filename
Trim $filename

{forbidden Windows filename characteres are < > : " / \ | ? *}

StringPos #f1 "<" $filename
StringPos #f2 ">" $filename
StringPos #f3 ":" $filename
StringPos #f4 '"' $filename
StringPos #f5 "/" $filename
StringPos #f6 '\' $filename
StringPos #f7 "|" $filename
StringPos #f8 "?" $filename
StringPos #f9 "*" $filename

:forbiddencheck

if #f1 > 0 then f1
if #f2 > 0 then f2
if #f3 > 0 then f3
if #f4 > 0 then f4
if #f5 > 0 then f5
if #f6 > 0 then f6
if #f7 > 0 then f7
if #f8 > 0 then f8
if #f9 > 0 then f9

AddStrings $filepath $filename

{FileExists &fe $filepath}
{If &fe then duplicate}

SaveMessageToFile %message $filepath

Exit

{:duplicate}
{if file already exists, we add the date to the file name to go unique}
{ReadHeader $date "Date:" %message
{Set $filename ""
{Set $filepath $apppath
{AddStrings $filename $subject $uid $date
{Trim $filename
{AddStrings $filepath $filename
{SaveMessageToFile %message $filepath

{FORBIDDEN CHARS IN FILE NAME SUBROUTINES:}

:f1
SubStrings $filename "<"
StringPos #f1 "<" $filename
MessageBox "f1"
Goto forbiddencheck   

:f2
SubStrings $filename ">"
StringPos #f2 ">" $filename
Goto forbiddencheck   

:f3
SubStrings $filename ":"
StringPos #f3 ":" $filename
MessageBox "f3"
Goto forbiddencheck   

:f4
SubStrings $filename '"'
StringPos #f4 '"' $filename
Goto forbiddencheck

:f5
SubStrings $filename "/"
StringPos #f5 "/" $filename
Goto forbiddencheck   
   
:f6
SubStrings $filename '\'
StringPos #f6 '\' $filename
Goto forbiddencheck   

:f7
SubStrings $filename "|"
StringPos #f7 "|" $filename
Goto forbiddencheck   

:f8
SubStrings $filename "?"
StringPos #f8 "?" $filename
Goto forbiddencheck   

:f9
SubStrings $filename "*"
StringPos #f9 "*" $filename
Goto forbiddencheck   


Currently Save to EML function in File menu doesn't take into account same subjects if you use %subject% for a file name, thus if you have two messages with same subject selected, only one of them will be saved. Above script allows EML saving until it will be fixed. The only other alternative besides this script, is to forget %subject% variable and use any word you wish, then all messages will be saved in a format "word+number.eml", where number gets incremented.
Tomas
Tomas
Pillar of the Community
 
Posts: 1418
Joined: Sun Jul 25, 2004 1:34 am

Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 2 guests

cron