From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX"  2-FEB-1993 22:21:58.97
To:	info-vax@kl.sri.com
CC:	
Subj:	summary: converting VMS mail to u*x

I posted the following to the net:
>Could anyone tell me how to convert my VMS mail to un*x format (ultrix,
>unix, whatever)? Is there a utility for this? I'm trying to move my mail to
>a different computer, and it's a lot of mail.
and quickly received several replies. 

Larry Hughes suggesed making a utility using portions of IUPOP3 code, since
POP3 performs this same conversion as part of its job. See the appended
full text for details.

Carl Lydick and Norman Hill  both suggesed extracting the mail to a text
file, then editing that as required by the particular u*x mail format
required. Normal Hill even supplied a gawk script. See the appended full
text for details.

Jim Belonis (our computer manager) found a simple utility that claims to do
the job. I have appended the code to this message. Unfortunately, it has
not worked for us. He thinks he can fix it, but in any case it does not
appear to addresses very cleverly, so Larry Hughes' solution (or mine
below, if your target has a POP3 client) seems like a better bet.

My target computer is a Macintosh running Eudora, a POP3 client. So in lieu
of existing conversion utilities, the simplest solution for me appears to
be to run a POP3 server on the VAX, then read the mail using Eudora. Eudora
keeps its mail in bsd unix format--hence the original posting--so if you
are desperate you can use a Mac as an intermediary to convert VMS mail to
bsd unix mail.

Thanks for all your help.

-- Russell
Russell E. Owen
owen@astro.washington.edu

Full text of the replies (including code for the utility).

----- From: larry hughes <hughes@logos.ucs.indiana.edu> -----

I've thought about this a lot myself.  I haven't done it yet, but
it would be easy to take portions of IUPOP3 source code and make
it do what you want.  It does read VMS mail folders after all, and
convert the messages into UNIX-style for network delivery to POP3 
clients.

The work would be 95% removing code, and 5% adding some code. The
key routines you'd want are in IUPOP3_VMS.C.

If interested, anonymous ftp to logos.ucs.indiana.edu (129.79.17.29)
and look in /pub/iupop3.

----- From: Carl J Lydick <carl@SOL1.GPS.CALTECH.EDU> -----

In article <owen-290193103604@rowen.astro.washington.edu>, you write:
>Could anyone tell me how to convert my VMS mail to un*x format (ultrix,
>unix, whatever)? Is there a utility for this? I'm trying to move my mail to
>a different computer, and it's a lot of mail.

Your first step is to issue the command:
        $ EXTRACT/ALL/MAIL some_file.type
This will create a sequential mail file containing all the messages from
the
current folder.  You can then use whatever means you prefer (editor, gawk
script, C program...) to convert it to the format used by whichever Unix
system
you wish to move it to.

----- From: Norman Hill <hillnr@hamlet.uncg.edu> -----

A little over a year ago I started managing our Ultrix boxes on campus
and decided to move all my mail folders over.  I wanted to keep the work
to a minimum and keep folders intact.

    Here is what I did:

      1. Extracted the folders I wished to move with the

         EXTRACT/MAIL command

      2. Used ftp (or some other means of copying) to move the files to
         the unix machine.

      3. I then used gawk (GNU's awk program, but I think nawk should work
         just as well) with the program listed below to convert the file
into
         a standard unix mail folder format.

         If you store the program in a file called "vms2unix", then you
         could use the command line:

                     nawk -f vms2unix vmsmailfile > newmailfile

############## gawk (or nawk) program starts here ################
/\f/ { print "";
       getline;
       fromline = $0;
       sub(/:\t/,"  ",fromline)
       sub(/ "[^"]*"/,"",fromline);
       split(fromline,from);
       sub(/IN%/,"",from[2]);gsub(/"/," ",from[2]);
       split(from[3],date,/-/);
       print from[1] " " from[2]\
             " ? " date[2] " " date[1] " " from[4] " " date[3];
       print $0;
       getline;sub(/^To:\t/,"To:     ");print;
       getline;sub(/^CC:\t/,"CC:     ");print;
       getline;sub(/^Subj:\t/,"Subj:   ");print;
       print "Status: OR";
       getline}
{print}
############# program ends here (delete this line and the start line) ###

------ a conversion utility written by fox@vulcan.noarl.navy.mil --------

C From: fox@vulcan.noarl.navy.mil (Dan Fox)
C 
C I just sent this to Francisco...  It was how I converted all the VAX
C mail folders over to files that unix mail would understand.  There were
C a few reported failures, but it handled all my mail folders properly.
C 
C 
c--------------------------------------------------------------
c  program:  mailfix
c--------------------------------------------------------------
c  purpose:  convert VAX mail to UNIX
c--------------------------------------------------------------
c  version:  1.0 : 25 Oct 1989 : D N Fox : NORDA Code 323
c--------------------------------------------------------------
c  procedure:
c     1. On the VAX side, if you have any new mail, read it
c        and exit MAIL so that when you come back into MAIL,
c        you have no new messages.
c     2. Select all messages using something like:
c             mail> select/since=01-jan-1900
c     3. Save all these to a file:
c             mail> extract/all dua10:[scratch.you]vax.mail
c     4. ftp this file to your Sun
c     5. On the Sun side, run the 'mailfix' program:
c             cat vax.mail | mailfix > mbox_vax
c     6. Now you can read 'mbox_vax' as a normal mailbox.
c        In Mailtool, you can enter this name on the file line
c        and click on the 'folder' button.  
c--------------------------------------------------------------
      character*1 buffer(200000)
      nchar=1
      do imsg=1,9999
c  read until a ^L (or EOF) is encountered
        call getmsg(buffer,200000,nchar,ierr)
c  if this is a real message, fix it and write it out
        if(nchar.gt.1) then
          call fixmsg(buffer,nchar)
          call putmsg(buffer,nchar)
        endif
c  set up for remainder of next msg
        buffer(1)=char(12)
        nchar=2
c  did we run into EOF?
        if(ierr.ne.0) call exit(0)
      enddo
      end
c--------------------------------------------------------------
      subroutine getmsg(msg,maxlen,nchar,ierr)
c--------------------------------------------------------------
c  on entry, nchar points to where to put the first character
c  read.  on exit, nchar points to the last valid character
      character*1 c,newpag,msg(*)
      integer getc
      newpag=char(12)
      i1=nchar
      do i=i1,maxlen
c  read a character
        ierr=getc( c )
c  if EOF, return
        if(ierr.ne.0) return
c  if it's a ^L character just return with what we've got so far
        if(c.eq.newpag) return
c  otherwise, save it...
        msg(i)=c
        nchar=i
      enddo
c  if we get here, we ran out of space - that's an error!!
      return
      end
c--------------------------------------------------------------
      subroutine fixmsg(msg,nchar)
c--------------------------------------------------------------
      character*1 msg(*)
      character*5 test
c  make sure we have one that needs fixing...
      do i=1,5
        test(i:i)=msg(2+i)
      enddo
      if(test.eq.'From:') then
c  replace FF by CR 
        msg(1)=msg(2)
c  replace colon by space
        msg(7)=' '    
      endif
      return
      end
c--------------------------------------------------------------
      subroutine putmsg(msg,nchar)
c--------------------------------------------------------------
      character*1 c,msg(*)
      integer putc
      do i=1,nchar
        c=msg(i)
        ierr=putc( c )
      enddo
      return
      end