home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / MBLIB10 / C_EXAMP / ECHO2NET.C next >
Text File  |  1993-03-07  |  1KB  |  40 lines

  1. /* Find all unread mail to me, then copy it into a netmail, also to me */
  2. /* This demo doesn't mark mail as 'Rcvd' afterwards!!                  */
  3.  
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "mb_lib.h"
  9.  
  10. int putln (char *); /* proto */
  11.  
  12. void main () {
  13.   MSGTOIDX_RECORD myname = "Frank Van.wensveen";
  14.   MSGHDR_RECORD msghdr;                            /* Echomail header */
  15.   NET_RECORD nethdr;                               /* Netmail header  */
  16.   M_TEXT msgtxt;                                   /* Text handle     */
  17.   char msgpath [MAXPATH];
  18.   long msgnr;
  19.  
  20.   strcpy (msgpath, "C:\\MSGBASE");     /* Fill in your own path */
  21.   if (msg_open (msgpath)) {
  22.     puts ("Error opening message base");
  23.     exit (-1);
  24.   }
  25.   clrscr ();
  26.   msgnr = msg_firstto (& myname);                  /* Find mail to me  */
  27.   while (msgnr != -1) {
  28.     msg_read_hdr (msgnr, & msghdr);                /* Read header      */
  29.     net_hdr_clear (& nethdr);
  30.     strcpy (nethdr.who_from, msghdr.who_from);     /* Copy to net hdr  */
  31.     strcpy (nethdr.who_to, msghdr.who_to);
  32.     strcpy (nethdr.subject, msghdr.subject);
  33.     printf ("Msg. nr. %d --> netmail\n", msghdr.msgnum);
  34.     msgtxt = msg_read_text (& msghdr);             /* Read msg text    */
  35.     net_write (msgpath, net_last (msgpath) + 1, & nethdr, msgtxt);
  36.     msgnr = msg_nextto (msgnr);                    /* Write and repeat */
  37.   }
  38.   msg_close ();
  39. }
  40.