/* tclmapi.c - Tcl interface to MAPI.
|
/* tclmapi.c - Tcl interface to MAPI.
|
Copyright (C) 1997 Cygnus Solutions
|
Copyright (C) 1997 Cygnus Solutions
|
Written by Tom Tromey <tromey@cygnus.com>. */
|
Written by Tom Tromey <tromey@cygnus.com>. */
|
|
|
#ifdef _WIN32
|
#ifdef _WIN32
|
|
|
#include <windows.h>
|
#include <windows.h>
|
#include <mapi.h>
|
#include <mapi.h>
|
|
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <tcl.h>
|
#include <tcl.h>
|
|
|
#include "guitcl.h"
|
#include "guitcl.h"
|
#include "subcommand.h"
|
#include "subcommand.h"
|
|
|
/* Usage for the mapi command:
|
/* Usage for the mapi command:
|
mapi simple-send TO-ADDRESS SUBJECT TEXT.
|
mapi simple-send TO-ADDRESS SUBJECT TEXT.
|
|
|
This command has been deliberately kept very simple; it only does
|
This command has been deliberately kept very simple; it only does
|
what we need. However it can be extended by adding new subcommands
|
what we need. However it can be extended by adding new subcommands
|
if necessary. */
|
if necessary. */
|
|
|
static int
|
static int
|
mapi_command (ClientData cd, Tcl_Interp *interp, int argc, char *argv[])
|
mapi_command (ClientData cd, Tcl_Interp *interp, int argc, char *argv[])
|
{
|
{
|
MapiMessage message;
|
MapiMessage message;
|
MapiRecipDesc to;
|
MapiRecipDesc to;
|
ULONG result;
|
ULONG result;
|
|
|
message.ulReserved = 0;
|
message.ulReserved = 0;
|
message.lpszSubject = argv[3];
|
message.lpszSubject = argv[3];
|
message.lpszNoteText = argv[4];
|
message.lpszNoteText = argv[4];
|
message.lpszMessageType = NULL;
|
message.lpszMessageType = NULL;
|
message.lpszDateReceived = NULL;
|
message.lpszDateReceived = NULL;
|
message.lpszConversationID = NULL;
|
message.lpszConversationID = NULL;
|
message.flFlags = 0;
|
message.flFlags = 0;
|
message.lpOriginator = NULL;
|
message.lpOriginator = NULL;
|
message.nRecipCount = 1;
|
message.nRecipCount = 1;
|
message.lpRecips = &to;
|
message.lpRecips = &to;
|
message.nFileCount = 0;
|
message.nFileCount = 0;
|
message.lpFiles = NULL;
|
message.lpFiles = NULL;
|
|
|
to.ulReserved = 0;
|
to.ulReserved = 0;
|
to.ulRecipClass = MAPI_TO;
|
to.ulRecipClass = MAPI_TO;
|
to.lpszName = "";
|
to.lpszName = "";
|
/* FIXME: smtp:address? */
|
/* FIXME: smtp:address? */
|
to.lpszAddress = argv[2];
|
to.lpszAddress = argv[2];
|
to.ulEIDSize = 0;
|
to.ulEIDSize = 0;
|
to.lpEntryID = NULL;
|
to.lpEntryID = NULL;
|
|
|
result = MAPISendMail (0, 0, &message, MAPI_LOGON_UI, 0);
|
result = MAPISendMail (0, 0, &message, MAPI_LOGON_UI, 0);
|
if (result != SUCCESS_SUCCESS)
|
if (result != SUCCESS_SUCCESS)
|
{
|
{
|
/* We could decode the error here. */
|
/* We could decode the error here. */
|
char buf[20];
|
char buf[20];
|
|
|
sprintf (buf, "0x%lx", result);
|
sprintf (buf, "0x%lx", result);
|
Tcl_AppendResult (interp, argv[0], ": failed with status ",
|
Tcl_AppendResult (interp, argv[0], ": failed with status ",
|
buf, (char *) NULL);
|
buf, (char *) NULL);
|
return TCL_ERROR;
|
return TCL_ERROR;
|
}
|
}
|
|
|
return TCL_OK;
|
return TCL_OK;
|
}
|
}
|
|
|
static const struct ide_subcommand_table mapi_table[] =
|
static const struct ide_subcommand_table mapi_table[] =
|
{
|
{
|
{ "simple-send", mapi_command, 5, 5 },
|
{ "simple-send", mapi_command, 5, 5 },
|
{ NULL, NULL, 0, 0 }
|
{ NULL, NULL, 0, 0 }
|
};
|
};
|
|
|
int
|
int
|
ide_create_mapi_command (Tcl_Interp *interp)
|
ide_create_mapi_command (Tcl_Interp *interp)
|
{
|
{
|
return ide_create_command_with_subcommands (interp, "ide_mapi",
|
return ide_create_command_with_subcommands (interp, "ide_mapi",
|
mapi_table, NULL, NULL);
|
mapi_table, NULL, NULL);
|
}
|
}
|
|
|
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
|
|