MIGLESIAS@UCIVMSA.BITNET.UUCP (04/11/87)
Since there's been so much discussion of the formats of the mail files
on info-vax lately, I'm posting this document that I wrote over a year ago.
Mike Iglesias
University of California, Irvine
---------------------------------------------------------------------------
17-Jan-86
VMS MAIL file formats
Disclaimer: I don't guarantee the following information is
totally correct. It is based on reading the
microfiche and looking at mail files. This
information was derived from the VMS 4.0
microfiche. Use at your own risk.
If you find any errors, have any new information
to add, etc., you can send them to me at the
following addresses:
BITNET: MIGLESIAS@UCIVMSA
ARPAnet: MIGLESIAS%UCIVMSA.BITNET@WISCVM.WISC.EDU
US Mail: Mike Iglesias
University of California
Computing Facility
Irvine, Ca 92717
Overview
--------
There are two file formats used in the VMS MAIL system: The
format for SYS$SYSTEM:VMSMAIL.DAT and the format for MAIL.MAI.
SYS$SYSTEM:VMSMAIL.DAT has information on any forwarding set
for each user, any directory (other than the login directory)
where his mail file is, and a personal name. MAIL.MAI (really
*.MAI) is the file in each user's account that actually contains
the mail messages.
I've tried to use the names DEC used in the file MAILDEF.SDL
(fiche 228) wherever I could.
Format of SYS$SYSTEM:VMSMAIL.DAT
--------------------------------
The SYS$SYSTEM:VMSMAIL.DAT (hereafter refered to as VMSMAIL.DAT)
file is a keyed file. The key is the USERNAME, blank filled to
31 characters.
Record format:
Field name Type Size Contents
------------- -------------- --------------- --------------------------
USERNAME character 31 bytes USERNAME
FLAGS bit unsigned word MAIL flags
NEWMAIL number unsigned word New mail count
SPARE spare area 7 longwords
SPARE1 spare area 2 bytes
DIRLNG number unsigned byte Length of dir name if set
FNMLNG number unsigned byte Length of personal name
FWDLNG number unsigned byte Length of forward address
if any of the last three items are set non-zero, the strings
that they describe the length of follow in this order:
Forward address
Personal name
Directory name
The FLAGS field contains the following flags:
Flag name Bit Hex value Meaning
------------- ----- ----------- ----------------------------------
SELFSEND 0 0001 Send a copy to self on a SEND
SELFREPLY 1 0002 Send a copy to self on a REPLY
NOAUTOPURGE 2 0004 Don't autopurge on EXIT or ^Z
The minimum record length is 68 bytes. The maximum is 833 (I think),
but be forwarned that SYS$EXAMPLES:MAILUAF.COM appears to only handle
records up to 255 bytes long.
To find the user's MAIL.MAI file, you need the device and directory
from their SYSUAF record and the directory name from VMSMAIL.DAT (if
DIRLNG is non-zero).
Format of MAIL.MAI (or any other mail file name)
------------------------------------------------
Each record in the actual mail file (MAIL.MAI, etc) has two keys -
the data/time the message was received, and the folder to which it
belongs. The keys are in the 'common header' portion of the record,
which each record in the file has at the begining.
The 'common' part of the record looks like this:
Field name Type Size Contents
------------- -------------- --------------- --------------------------
DATIM date/time quadword date/time field
FILKEYLEN count unsigned byte Length of data in FILEKEY
FILEKEY character 39 bytes Filing key (FOLDER name)
(The keys are DATIM and FILEKEY)
If the high longword of the DATIM field is zero, then this is an info record,
and the low longword is the info record type. Info record types are:
Code Meaning
---- ------------------------------------------------
1 LASTREAD - date/time of last read message (not used?)
2 WASTENAME - name of wastebasket folder
3 FILEINFO - file information
4 MW - mailwatch info (not used?)
5 NEWMSG - new message info (not used?)
It appears that there is always a type 3 record (FILEINFO) and, if
you use the SET WASTEBASKET_NAME command, there will be a type 2
(WASTENAME) record. Formats for FILEINFO and WASTENAME records
are:
FILEINFO:
Field name Type Size Contents
------------- -------------- --------------- --------------------------
('common' header)
DELETEDBYTES count lognword # of deleted bytes in file
WASTENAME:
Field name Type Size Contents
------------- -------------- --------------- --------------------------
('common' header)
LENGTH count unsigned byte length of folder name
WASTENAME character LENGTH bytes name of wastebasket folder
A record in the mail file can be at most 2048 bytes long.
Message header record
---------------------
Each message in the mail file has a message header record. The message
header record has the 'common' header, followed by the mail header.
The 'common' header has the folder that the message is in in the
FILEKEY field, with the length of the folder name in FILKEYLEN.
The mail header has the following format:
Field name Type Size Contents
------------- -------------- --------------- --------------------------
('common' header)
FLAGS bit unsigned word message flags
FLAGSIZ count unsigned byte size of flag string if ASCII
FLAGVAL unknown unsigned longwd value of /FLAG=
HDSPARE spare byte spare byte to align data
DATID date/time quadword Key id of message text rec
variable data (see below)
The variable data contains the 'from', 'to', etc. data for the message.
The variable data is formatted as follows
Field name Type Size Contents
------------- -------------- --------------- --------------------------
CODE value word variable data code
LENGTH count unsigned word length of variable data
DATA depends on data LENGTH bytes data
The codes and their data types are:
Code Data type
------- ----------------------------------------
0 'From' text string
1 'to' text string
2 'subject' text string
3 'cc' text string
4 mailwatch info - unknown data type
5 number of records in message
6 spec of external file (not used)
Codes 7-32767 are reserved to DIGITAL, 32768-65535 are reserved for
customers.
The FLAGS field contains the following flags:
Flag name Bit Hex value Meaning
------------- ----- ----------- ----------------------------------
NEWMSG 0 0001 This is a new message
REPLIED 1 0002 This message has been replied to
SKIP1 2 0004 spare bit
EXTMSG 3 0008 message is in an external file
SYSMSG 4 0010 message is in system file
If the EXTMSG flag is set, the DATID is used as part of the file
name after it is made into printable ASCII. For instance, if the
DATID field contains hex '0004008E5BA9F107', the external file name
would be 'MAIL$0004008E5BA9F107.MAI;1'.
Message Text record
-------------------
The message text record contains the actual text of a mail message
unless the EXTMSG flag is set in the header record. Each message text
record contains 1 or more message text lines. A message text
record has the following format:
Field name Type Size Contents
------------- -------------- --------------- --------------------------
('common' header)
LENGTH count unsigned word length of message text line
DATA character LENGTH bytes message text line
The LENGTH and DATA are repeated for each message text line in the
message (the number of records in the message text are in the mail message
header; see above), up to the length of the record.
The only field in the 'common' header part of the message text record
that is filled in is the DATIM field, which is the same as the DATID
field in the message header record for this message text.
If the message resides in an external file, the file is a variable
length sequential file (carriage return carriage control).