2 * Dumb program to send an email message
5 * email -s "Subject" address@somewhere.com -m "Body of text"
7 * Kern Sibbald, October MM
15 extern void mainCRTStartup();
16 void WinMainCRTStartup() { mainCRTStartup(); }
19 int main(int argc
, char **argv
)
25 MapiMessage emsg
= {0,
26 "Apcupsd message", /* default subject */
27 "No text specified.\n", /* default message text */
28 NULL
, NULL
, NULL
, 0, NULL
,
32 recip
.ulRecipClass
= MAPI_TO
;
33 recip
.lpszName
= "root"; /* default name */
34 recip
.lpszAddress
= "SMTP:root"; /* default address */
36 recip
.lpEntryID
= NULL
;
38 for (i
=1; i
<argc
; i
++) {
39 if (strcmp(argv
[i
], "-s") == 0) { /* Subject */
41 emsg
.lpszSubject
= argv
[i
];
42 } else if (strcmp(argv
[i
], "-m") == 0) { /* Message text */
44 emsg
.lpszNoteText
= argv
[i
];
45 } else { /* address */
46 strncpy(addr
, "SMTP:", sizeof(addr
));
47 strncat(addr
, argv
[i
], sizeof(addr
));
48 recip
.lpszAddress
= addr
;
49 recip
.lpszName
= argv
[i
];
53 err
= MAPISendMail(0L, 0L, &emsg
, 0L, 0L);
55 if (err
!= SUCCESS_SUCCESS
) {
57 snprintf(buf
, sizeof(buf
), "MAPI error code = %d", (int)err
);
59 // Note, if we put up a dialogue box, this may stall the
60 // calling script, not a good thing.
61 // MessageBox(NULL, buf, "Error", MB_OK);