Article View: news.software.readers
Article #221625Re: [dialog] how to archive Sent messages?
From: vince
Date: Mon, 02 Jun 2008 11:13
Date: Mon, 02 Jun 2008 11:13
253 lines
8137 bytes
8137 bytes
On Mon, 2 Jun 2008 15:31:56 +1000, Rom <-@-.invalid> wrote:
>Can you please post the changed script to save all in
>the one file, or clues to what parts in the script need to be changed?
Made all the changes you suggested, with one exception. I sorted the Sent
messages folder by date with the oldest at the top. I start at the top and
use the down arrow to step through the messages.
The filename is hard coded in the script. A slicker change would have been
to make it a variable - but this was a quick and dirty change - and I'm not
a programmer.
Think line length long enough but watch the word wrap, if you cut and paste
from a newsreader.
Program FileSubject; //v0.3 by MLC
uses Forms, StdCtrls, Textfile;
//---------------------------- Settings ---------------------------------//
const
path = 'C:\temp\';
// write the path of the folder where you want the file to be created
// notice that the last character must be a back slash \
fileUnique = 1; // possible values: 1 or 0
// If fileUnique = 1 every Subject will have a unique file
// and every follow-up will be added in this same file.
// if fileUnique = 0 every message will be saved in a different file
// (Subject.txt, Subject[01].txt, Subject[02].txt,...).
allHeaders = true; // all headers saved? true/false.
// If false the saved headers are only From, Subject, Newsgroups, Date, Message-ID.
//------------------------ End of Settings -----------------------------//
//(you don't need to change anything else in this script)
type
TNoChars=set of Char;
var
FileHandle: Integer;
fileName, temp: string;
areHid: boolean;
myForm: TForm;
myMemo: TMemo;
Function EmptyClipboard:boolean; external 'EmptyClipboard@user32.dll stdcall';
Function OpenClipboard(hWndNewOwner: INTEGER):boolean; external 'OpenClipboard@user32.dll stdcall';
Function CloseClipboard:boolean; external 'CloseClipboard@user32.dll stdcall';
Procedure ClearClipboard;
{to avoid side effects: if an empty selection must be copyed in the clipboard}
begin
OpenClipboard(0);
EmptyClipboard;
CloseClipboard;
end;
function GetMsgBody: string;
begin
lockdisplay;
try
myMemo.Clear;
ClearClipboard;
ADo('ArticlePane');
ADo('SelectAll');
Ado('Copy');
myMemo.PasteFromClipboard;
finally
unlockdisplay;
end;
result:=myMemo.Text;
end;
function GetMsgInfo(field: string): string;
var
i: integer;
begin
i:=0;
result:='';
while i < myMemo.Lines.count-1 do
begin
if pos(field, myMemo.Lines[i])>0 then break;
i:=i+1;
end; //while
result:=myMemo.Lines[i];
end;
function GetMsgSubject: string;
var
i: integer;
begin
i:=0;
result:='';
while i < myMemo.Lines.count-1 do
begin
if pos('Subject:', myMemo.Lines[i])>0 then break;
i:=i+1;
end; //while
result:=copy(myMemo.Lines[i],10,length(myMemo.Lines[i]));
end;
function DelSign(sSign : string; sString : string): string;
begin
result:=StringReplace(sString, sSign, '_', [rfReplaceAll]);
end;
function Adjust(s: string): string;
var
i: integer;
noChars: TNoChars;
begin
if copy(s,1,3)='Re:' then
s:=copy(s, 5, length(s)-1)
else if (copy(s,1,2)='R:') then
s:=copy(s, 4, length(s)-1);
noChars:=[':', '/', '\', '*', '|', '<', '>', '?', '"'];
i:=1;
while (i<=length(s)) do
begin
if s[i] in noChars then
begin
s:=DelSign(s[i], s);
continue;
end;
i:=i+1;
end;
result:=s;
end;
function ChangeName(var file: string): string;
var
len, digits: integer;
fn, base, digitsStr: string;
begin
fn:=ExtractFileName(file);
len:=length(fn);
base:=copy(fn, 1, len-7);
digitsStr:='';
digitsStr:=copy(fn, len-6, 2);
digits:=StrToInt(digitsStr);
digits:=digits+1;
if length(IntToStr(digits))=1 then digitsStr:='0'+IntToStr(digits)
else digitsStr:=IntToStr(digits);
file:=path+base+digitsStr+'].txt';
if FileExists(file) then result:=ChangeName(file)
else result:=file;
end;
function AreHeadHid: boolean;
var i: integer;
begin
result := true;
if myMemo.Lines.count > 10 then
begin
i:=0;
while (i < myMemo.Lines.count-1) and result do
begin
i:= i+1;
result := pos('Newsgroups: ', myMemo.Lines.strings[i])=0;
end; //while
end; //if
end;
procedure BuildMyMemo;
begin
myMemo:=tMemo.Create(myForm);
myMemo.parent:=myForm;
myMemo.width := Application.Mainform.width;
end;
procedure WriteF;
var
ps: string;
f: TextFile;
begin
temp:=Adjust(GetMsgSubject);
ps:=path;
if (ps[length(ps)]<>'\') then
begin
writeln(ps[length(ps)-1]);
Application.MessageBox('your path doesn''t end with \ ', 'Error !', 1);
exit;
end;
if DirectoryExists(path) then
//fileName:=path+temp+'.txt'
fileName:=path+'dialog.sent.messages.txt'
else
begin
Application.MessageBox('your path doesn''t exist!', 'Error !', 1);
exit;
end;
case fileUnique of
1:
begin
//myMemo.Lines.Add(#13+#10+StringOfChar('*', 75)+#13+#10+#13+#10);
myMemo.Lines.Add(#13+#10);
AssignFile(f, fileName);
if fileexists(filename) then append(f)
else rewrite(f);
TextWrite(f, myMemo.text);
CloseFile(f);
end;
0:
begin
if (FileExists(fileName)) then
begin
fileName:=path+temp+'[00].txt';
fileName:=ChangeName(fileName);
end;
FileHandle := FileCreate(fileName);
FileWrite(FileHandle, myMemo.text, length(myMemo.text));
FileClose(FileHandle);
end;
else
Application.MessageBox('fileUnique must be 0 or 1', 'Error !', 1);
end;
end;
Begin
myForm:=TForm.Create(nil);
temp:='';
lockdisplay;
try
BuildMyMemo;
GetMsgBody;
areHid:=AreHeadHid;
if areHid then ADo('ShowHeaders');
GetMsgBody;
if not allHeaders then
begin
temp:=GetMsgInfo('From:')+#13#10+GetMsgInfo('Subject:')+#13#10+GetMsgInfo('Newsgroups:');
temp:=temp+#13#10+GetMsgInfo('Date:')+#13#10+GetMsgInfo('Message-ID:')+#13#10+#13#10;
ADo('ShowHeaders');
temp:=temp+GetMsgBody;
myMemo.Text:=temp;
ADo('ShowHeaders');
end;
WriteF;
if areHid then Ado('ShowHeaders');
finally
unlockdisplay;
myForm.free;
//next 2 lines added to original script
ADo('HeaderlistPane');
PostKey(40, false, false, false, false, false, false, false, false);
end;
End.
Technical Details
Message-ID:
<671dh5-0qn.ln1@home.invalid>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nlpi057.nbdc.sbc.com!prodigy.net!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!bf1ed865!not-for-mailReferences:
<gfr7h5-6gj.ln1@home.invalid> <7o1ttw4x1jow.rv1i41yguzzc$.dlg@40tude.net> <ginah5-mal.ln1@home.invalid> <1qilh76b2sfqo.1agd42rn1aulh$.dlg@40tude.net> <uohbh5-rtc.ln1@home.invalid> <1j3b45u7zep5m$.1wkl5ae5f87zj.dlg@40tude.net>Show Full Headers
Complete Article Headers
Message-ID: <671dh5-0qn.ln1@home.invalid> Subject: Re: [dialog] how to archive Sent messages? Date: Mon, 02 Jun 2008 11:13:41 GMT From: vince <nobody@home.invalid> References: <gfr7h5-6gj.ln1@home.invalid> <7o1ttw4x1jow.rv1i41yguzzc$.dlg@40tude.net> <ginah5-mal.ln1@home.invalid> <1qilh76b2sfqo.1agd42rn1aulh$.dlg@40tude.net> <uohbh5-rtc.ln1@home.invalid> <1j3b45u7zep5m$.1wkl5ae5f87zj.dlg@40tude.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nlpi057.nbdc.sbc.com!prodigy.net!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!bf1ed865!not-for-mail Newsgroups: news.software.readers X-Newsreader: Forte Agent 2.0/32.652 X-No-Archive: yes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 253 NNTP-Posting-Host: 73201556e7f1afd452eebf66dfed8c2b X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1212405221 NNTP-Posting-Date: Mon, 02 Jun 2008 11:13:41 GMT