<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MAIL.MAI file structure in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982812#M23213</link>
    <description>Hello All!&lt;BR /&gt;&lt;BR /&gt;I looking for legal structure definition MAIL.MAI file, I'd like to write some application to perfrom an automatic repair ofr VMS mailboxes.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TIA.</description>
    <pubDate>Sun, 04 Jun 2006 02:24:30 GMT</pubDate>
    <dc:creator>Ruslan R. Laishev</dc:creator>
    <dc:date>2006-06-04T02:24:30Z</dc:date>
    <item>
      <title>MAIL.MAI file structure</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982812#M23213</link>
      <description>Hello All!&lt;BR /&gt;&lt;BR /&gt;I looking for legal structure definition MAIL.MAI file, I'd like to write some application to perfrom an automatic repair ofr VMS mailboxes.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TIA.</description>
      <pubDate>Sun, 04 Jun 2006 02:24:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982812#M23213</guid>
      <dc:creator>Ruslan R. Laishev</dc:creator>
      <dc:date>2006-06-04T02:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: MAIL.MAI file structure</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982813#M23214</link>
      <description>There is a utility called VFYMAIl (e.g. at &lt;A href="http://mvb.saic.com/freeware/vmslt03a/vu/)," target="_blank"&gt;http://mvb.saic.com/freeware/vmslt03a/vu/),&lt;/A&gt; which checks the integrity of your mail file and allows some repairs. I don't know if it satisfies your needs, but perhaps its worth a look.&lt;BR /&gt;&lt;BR /&gt;regards Kalle</description>
      <pubDate>Sun, 04 Jun 2006 06:55:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982813#M23214</guid>
      <dc:creator>Karl Rohwedder</dc:creator>
      <dc:date>2006-06-04T06:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: MAIL.MAI file structure</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982814#M23215</link>
      <description>Thanks Karl, I'll look this package. In the same time I interesting by MAIL-structure file provided by VMS-Eng.</description>
      <pubDate>Sun, 04 Jun 2006 07:05:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982814#M23215</guid>
      <dc:creator>Ruslan R. Laishev</dc:creator>
      <dc:date>2006-06-04T07:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: MAIL.MAI file structure</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982815#M23216</link>
      <description>You're not going to get an official definition.&lt;BR /&gt;It was never properly documented.&lt;BR /&gt;&lt;BR /&gt;The structure is easy enough though.&lt;BR /&gt;It is just on indexed file with a munged date and time stamp as primary key, and the older name as (duplicates allowed of course) alternate key.&lt;BR /&gt;The folder name has a byte count length.&lt;BR /&gt;The data is TLV (Tag, Length, Values).&lt;BR /&gt;There are Tags for Sender, Subject, CC, BCC and so on.&lt;BR /&gt;A quick DUMP/RECORD=COUNT=5 for a known MAIL.MAI will soon bring you up to speed.&lt;BR /&gt;&lt;BR /&gt;Here is a simple program to 'prove' the folder structure by asking RMS to count messages in a specified folder:&lt;BR /&gt;&lt;BR /&gt;#include &lt;RMS&gt;&lt;BR /&gt;#include &lt;STDIO&gt;&lt;BR /&gt;#define MYBUFSIZ 8192&lt;BR /&gt;char buf[MYBUFSIZ];&lt;BR /&gt;main (int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;struct FAB fab;&lt;BR /&gt;struct RAB rab;&lt;BR /&gt;int  i, stat;&lt;BR /&gt;&lt;BR /&gt;if (argc &amp;lt; 2) return 16;&lt;BR /&gt;fab = cc$rms_fab;&lt;BR /&gt;rab = cc$rms_rab;&lt;BR /&gt;fab.fab$b_shr = FAB$M_SHRPUT;&lt;BR /&gt;fab.fab$b_fac = FAB$M_GET;&lt;BR /&gt;if (argc &amp;gt; 2) fab.fab$l_fna = argv[2];&lt;BR /&gt;if (argc &amp;gt; 2) fab.fab$b_fns = STRLEN( argv[2] );&lt;BR /&gt;fab.fab$l_dna = "MAIL.MAI";&lt;BR /&gt;fab.fab$b_dns =  STRLEN( fab.fab$l_dna );&lt;BR /&gt;rab.rab$l_fab = &amp;amp;fab;&lt;BR /&gt;rab.rab$b_rac = RAB$C_KEY;&lt;BR /&gt;rab.rab$b_krf = 1;&lt;BR /&gt;rab.rab$l_ubf = buf;&lt;BR /&gt;rab.rab$w_usz = MYBUFSIZ;&lt;BR /&gt;rab.rab$l_kbf = argv[1];&lt;BR /&gt;rab.rab$b_ksz = STRLEN( argv[1] );&lt;BR /&gt;stat = SYS$OPEN ( &amp;amp;fab );&lt;BR /&gt;if (stat&amp;amp;1) stat = SYS$CONNECT ( &amp;amp;rab );&lt;BR /&gt;if (stat&amp;amp;1) stat = SYS$GET ( &amp;amp;rab ); /* establish next record pointer */&lt;BR /&gt;rab.rab$l_rop = RAB$M_LIM;&lt;BR /&gt;rab.rab$b_rac = RAB$C_SEQ;&lt;BR /&gt;for (i = 0; (stat&amp;amp;1) &amp;amp;&amp;amp; (stat!=RMS$_OK_LIM); i++) stat = SYS$FIND ( &amp;amp;rab );&lt;BR /&gt;printf ("%d messages\n", i);&lt;BR /&gt;return ;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And here is a script I made short while ago to construct a mail file to point to mail messages in a directory. It is readily extended to only add message not currently existing (orphans), and to report on messages with a missing external file (runaways).&lt;BR /&gt;&lt;BR /&gt;Once you crack the DCL below, plus that record dump, you will be well on your way to manipulate mail.mai files yourself.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$found_file = "FOUND.MAI"&lt;BR /&gt;$folder = "FOUND"&lt;BR /&gt;$sender = "Unknown"&lt;BR /&gt;$! yeah... there may be quicker ways to make nulls.&lt;BR /&gt;$null = "1234"&lt;BR /&gt;$null[0,32] = 0&lt;BR /&gt;$nulls = null + null + null + null + null + null + null + null + null + null&lt;BR /&gt;$record = f$extr(0,92+f$len(sender),nulls + nulls + nulls + nulls + nulls)&lt;BR /&gt;$record[8*8,8] = f$len(folder)&lt;BR /&gt;$record[9,f$len(folder)] := "''folder'"&lt;BR /&gt;$record[48*8,16] = 8                    ! External&lt;BR /&gt;$record[64*8,32] = %x00140007           ! Tag 7, Len 20, all zeroes&lt;BR /&gt;$record[90*8,16] = f$len(sender)        ! Tag 0 = from, Len from data&lt;BR /&gt;$record[92,f$len(sender)] := "''sender'"&lt;BR /&gt;$&lt;BR /&gt;$open/write found tmp.tmp&lt;BR /&gt;$loop:&lt;BR /&gt;$file = f$parse(f$search("mail$*.mai"),,,"NAME")&lt;BR /&gt;$if file.eqs."" then goto done&lt;BR /&gt;$record[2*8,16] = %x'f$extrac(9,4,file)&lt;BR /&gt;$record[4*8,16] = %x'f$extrac(5,4,file)&lt;BR /&gt;$record[6*8,16] = %x'f$extrac(17,4,file)&lt;BR /&gt;$record[60*8,32] = %x'f$extrac(13,8,file)&lt;BR /&gt;$record[56*8,32] = %x'f$extrac(5,8,file)&lt;BR /&gt;$write found record&lt;BR /&gt;$goto loop&lt;BR /&gt;$done:&lt;BR /&gt;$close found&lt;BR /&gt;$conv/fdl=sys$input tmp.tmp 'found_file&lt;BR /&gt;FILE; ALLOC 300; ORG INDEXED&lt;BR /&gt;RECORD; SIZE 2048&lt;BR /&gt;KEY 0;  SEG0_LEN 8; SEG0_POS 0; TYPE bin8&lt;BR /&gt;KEY 1;  DUP yes; CHANGES yes; SEG0_LEN 39; SEG0_POS 9&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And her is a message/folder counter usign the official api.&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO&gt;&lt;BR /&gt;#include &lt;MAILDEF&gt;&lt;BR /&gt;typedef struct { short len, cod; void *address; int *retlen; } item;&lt;BR /&gt;main (int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;int s, file_context = 0, msg_context = 0, msg_selected = 0;&lt;BR /&gt;item null[] = {0,0,0,0};&lt;BR /&gt;item msg_begin_in[] = {4,MAIL$_MESSAGE_FILE_CTX,&amp;amp;file_context,0, 0,0,0,0};&lt;BR /&gt;item msg_select_in[] = {0,MAIL$_MESSAGE_FOLDER,0,0, 0,0,0,0};&lt;BR /&gt;item msg_select_out[] = {4,MAIL$_MESSAGE_SELECTED,&amp;amp;msg_selected,0, 0,0,0,0};&lt;BR /&gt;&lt;BR /&gt;    if (argc &amp;lt; 2) return 16;&lt;BR /&gt;    msg_select_in[0].address = argv[1];&lt;BR /&gt;    msg_select_in[0].len = strlen(argv[1]);&lt;BR /&gt;            s = mail$mailfile_begin(&amp;amp;file_context,null,null);&lt;BR /&gt;    if (s &amp;amp; 1) s = mail$mailfile_open(&amp;amp;file_context,null,null);&lt;BR /&gt;    if (s &amp;amp; 1) s = mail$message_begin(&amp;amp;msg_context,msg_begin_in,null);&lt;BR /&gt;    if (s &amp;amp; 1) s = mail$message_select(&amp;amp;msg_context,&lt;BR /&gt;    msg_select_in,msg_select_out);&lt;BR /&gt;    printf ("%d messages in folder %s\n",msg_selected,argv[1]);&lt;BR /&gt;    return s; /* Actually... MAIL will Signal errors unless told not to */&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;/MAILDEF&gt;&lt;/STDIO&gt;&lt;/STDIO&gt;&lt;/RMS&gt;</description>
      <pubDate>Sun, 04 Jun 2006 11:01:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982815#M23216</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-06-04T11:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: MAIL.MAI file structure</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982816#M23217</link>
      <description>Ruslan,&lt;BR /&gt;&lt;BR /&gt;I've also found the MAIL_MAI_TOOLS helpful.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://groups.google.de/group/vmsnet.mail.pmdf/browse_frm/thread/472417b9a51cd031/6c8e37f9ab7d199a?lnk=st&amp;amp;q=stuffer+mail+vms&amp;amp;rnum=1&amp;amp;hl=de#6c8e37f9ab7d199a" target="_blank"&gt;http://groups.google.de/group/vmsnet.mail.pmdf/browse_frm/thread/472417b9a51cd031/6c8e37f9ab7d199a?lnk=st&amp;amp;q=stuffer+mail+vms&amp;amp;rnum=1&amp;amp;hl=de#6c8e37f9ab7d199a&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;These tools can re-construct a MAIL.MAI file from individual MAIL$nnn.MAI files. You can lean something about the MAIL.MAI record structures from STUFFER.FOR&lt;BR /&gt;&lt;BR /&gt;Volker.</description>
      <pubDate>Sun, 04 Jun 2006 11:33:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982816#M23217</guid>
      <dc:creator>Volker Halle</dc:creator>
      <dc:date>2006-06-04T11:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: MAIL.MAI file structure</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982817#M23218</link>
      <description>Thanks a lot to all!&lt;BR /&gt;Now I have what I'm need.</description>
      <pubDate>Sun, 04 Jun 2006 13:25:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/mail-mai-file-structure/m-p/4982817#M23218</guid>
      <dc:creator>Ruslan R. Laishev</dc:creator>
      <dc:date>2006-06-04T13:25:15Z</dc:date>
    </item>
  </channel>
</rss>

