$ send_line lelegard subject line_of_text
New mail on node LUTECE from SWTHOM::LELEGARD     "Thierry Lelegard" (10:55:19)
$

Example program send_line.c
---------------------------

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <descrip.h>
#include <ssdef.h>
#include <stsdef.h>
#include <maildef.h>
#include <starlet.h>

typedef struct {
    short length;
    short code;
    void  *buffer;
    short *retlen;
} ITEM;

#define SET_ITEM(item,func,buf,bufsize,retlength) (\
    (item).code   = (func),\
    (item).buffer = (buf),\
    (item).length = (bufsize),\
    (item).retlen = (retlength))

#define SET_ZITEM(item,func,buf) (\
    (item).code   = (func),\
    (item).length = strlen ((item).buffer = (buf)),\
    (item).retlen = NULL)

#define SET_FINAL_ITEM(item) (\
    (item).code   = 0,\
    (item).buffer = NULL,\
    (item).length = 0,\
    (item).retlen = NULL)

long mail$send_begin (long*, ITEM*, ITEM*);
long mail$send_add_address (long*, ITEM*, ITEM*);
long mail$send_add_attribute (long*, ITEM*, ITEM*);
long mail$send_add_bodypart (long*, ITEM*, ITEM*);
long mail$send_message (long*, ITEM*, ITEM*);
long mail$send_end (long*, ITEM*, ITEM*);

static void check (long status, char *name)
{
    if (!$VMS_STATUS_SUCCESS (status)) {
        printf ("%s status = %08X\n", name, status);
        status &= ~STS$M_INHIB_MSG;
        sys$exit (status);
    }
}

int main (int argc, char **argv)
{
    static ITEM empty [] = {{0, 0, NULL, NULL}};
    static short send_type = MAIL$_TO;

    long ctx = 0, status;
    ITEM items [4];
    int arg;

    if (argc < 3) {
        fprintf (stderr, "Syntax: send_line user-name subject line line ...\n")
        exit (SS$_NORMAL);
    }

    status = mail$send_begin (&ctx, empty, empty);
    check (status, "MAIL$SEND_BEGIN");

    SET_ZITEM (items [0], MAIL$_SEND_USERNAME, argv [1]);
    SET_ITEM (items [1], MAIL$_SEND_USERNAME_TYPE, &send_type,
        sizeof (send_type), NULL);
    SET_FINAL_ITEM (items [2]);

    status = mail$send_add_address (&ctx, items, empty);
    check (status, "MAIL$SEND_ADD_ADDRESS");

    SET_ZITEM (items [0], MAIL$_SEND_SUBJECT, argv [2]);
    SET_FINAL_ITEM (items [1]);

    status = mail$send_add_attribute (&ctx, items, empty);
    check (status, "MAIL$SEND_ADD_ATTRIBUTE");

    for (arg = 3; arg < argc; arg++) {
        SET_ZITEM (items [0], MAIL$_SEND_RECORD, argv [arg]);
        SET_FINAL_ITEM (items [1]);

        status = mail$send_add_bodypart (&ctx, items, empty);
        check (status, "MAIL$SEND_ADD_BODYPART,");
    }

    status = mail$send_message (&ctx, empty, empty);
    check (status, "MAIL$SEND_MESSAGE");

    status = mail$send_end (&ctx, empty, empty);
    check (status, "MAIL$SEND_END}");
}
