Article 157700 of comp.os.vms:
I am trying to write a C program to tell me how many new messages I have in a
particular mail folder.

I have some code to tell me how many messages I have in 'newmail',
and perhaps it could be easily modified for another folder. It is included
below.

My mail is filtered into different folders. Is it possible to not only tell me
how many messages are in a particular folder, but also how many of them haven't
been read?

Help would be much appreciated.
Thanks.
--
Robert Strahl

---C program---
#include <stdio.h>
#include <dvidef.h>
#include <maildef.h>

extern int mail$user_begin ();
extern int mail$user_end ();

/*
    In case you don't have MAIL.H yet
    #define MAIL$_USER_NEW_MESSAGES 3146
*/

typedef struct _vms_item_list {
	short	 buffer_length;
	short	 item_code;
	void	*buffer;
	int	*returned_buffer_length;
	} VMS_ItemList;


main ()
{
    int mail_context;
    unsigned  short new_messages;
    unsigned int length;

    VMS_ItemList in_itmlst [1] =
	{0, 0, 0, 0};


    VMS_ItemList out_itmlst [1] =
	{2, MAIL$_USER_NEW_MESSAGES, &new_messages, &length};


    mail_context = 0;

    mail$user_begin (&mail_context,
	    in_itmlst,
	    out_itmlst);

    if (new_messages != 1)
	printf ("\tYou have %d new mail messages.", new_messages);
    else
	printf ("\tYou have %d new mail message.", new_messages);

    mail$user_end (&mail_context,
	    in_itmlst,
	    in_itmlst);

}


