gawilcox has asked for the wisdom of the Perl Monks concerning the following question:

I really need to convert my Lotus Notes email to text as I have seen in previous posts. "buckaduck" posted a perl script to do it, but I'm having some problems with it and I sure could use some help because I'm definitely NOT a perl programmer. Specifically, I'd really like to have the messages named something other than "message.txt". I'd also like to get the attachments to download and MOST important, I would like to be able to store emails from my archive.nsf database. Is buckaduck still around? Is there anyone that can help - PLEASE???

Replies are listed 'Best First'.
Re: Store Lotus Notes Email
by hippo (Chancellor) on Mar 17, 2014 at 18:51 UTC

    buckaduck was here last month. You may or may not class that as being still around.

    You haven't linked to the post in question, but perhaps you meant this one? If so, it would be pretty trivial to have your output file named something other than "message.txt". One of the replies indicates that attachments are already catered for (and a cursory inspection of the script confirms this). That just leaves your additional NSF file which I presume you could re-import into your stock email NSF before running the script.

Re: Store Lotus Notes Email
by SamCG (Hermit) on Mar 18, 2014 at 10:24 UTC
    I have had a fairly simple script to pull lotus notes emails and dump the subject lines and bodies into a text file. If you want them in separate files it's not all that hard, but if you want to name a bunch of files with the subject line as the title keep in mind you'll need to get rid of '\/?:*"|<> Maybe if you posted our code here it would help?
    use Win32::OLE; my $server; my $database; my $folder; my $file = "temp_file.csv"; my $ini = "get_emails.ini"; if (-e $ini) { open (INI,$ini) || die "Not able to open $ini: $!\n"; chomp ($server ='' ); chomp ($database = ''); chomp ($folder = ''); } else { $server = 'servername'; $database = 'mail\user.nsf'; $folder = 'TargetFolder'; } #connect to the Notes database my $Notes = Win32::OLE->new('Notes.NotesSession') || warn "Cannot star +t Lotus Notes Session object: $!\n"; my $Database = $Notes->GetDatabase($server, $database); #Fetch contents of the folder my $Response = $Database->GetView($folder); my $Count = $Response->TopLevelEntryCount; my $Index = $Count; open (OUT, ">$file"); #loop through all emails for (1..$Count) { my $Document = $Response->GetNthDocument($Index--); my $subject = $Document->GetFirstItem('Subject')->{Text}; my $body = $Document->GetFirstItem('Body')->{Text}; print OUT "Subject: $subject\n", "Body: $body\n"; } ##`start excel.exe $file`;




    -----------------
    s''limp';@p=split '!','n!h!p!';s,m,s,;$s=y;$c=slice @p1;so brutally;d;$n=reverse;$c=$s**$#p;print(''.$c^chop($n))while($c/=$#p)>=1;
Re: Store Lotus Notes Email
by Ratazong (Monsignor) on Mar 18, 2014 at 10:32 UTC

    Hi,

    assuming you use the script here (as guessed by hippo), try to switch to the reply by NateTut and use his variant. There the filename is set by the line:

    my $FileName = sprintf("%04d_Message.txt", $num);
    You want to change this, e.g. by putting the subject in front
    my $FileName = $subdir ."_". sprintf("%04d_Message.txt", $num);
    If you want to access the received-date of the mail, you can have a look at $doc->{received}->[0]. This string contains the date/time (and more, so you have to extract it).

    HTH, Rata

Re: Store Lotus Notes Email
by gawilcox (Initiate) on Mar 18, 2014 at 09:05 UTC

    Thanks for your reply. I did, in fact, see that I am importing the attachments. I had missed that. So, that's OK. In the post that I found, someone else said that they had another script which creates a file with the subject, but I can't seem to get that one to work. One question though - you said that I could re-import into my stock email NSF before I run my script - how do I do that?

      No idea. Try doing the reverse of whatever you did to get them from your mail NSF to the archive.nsf in the first place. Or have a chat with your local Notes expert or IBM support. Either way, it is something to be done in the Notes client rather than from within Perl.