// Entry Parms
D fromAddress S 100A
D toAddress S 32767A
D ccAddress S 32767A
D bccAddress S 32767A
D subject S 32767A
D body S 32767A
//*************************************************************************
// External Subprocedures
/COPY MODULES/QSRVSRC,P.EMAIL
//*************************************************************************
// Entry Parms
C *entry plist
C parm fromAddress
C parm toAddress
C parm ccAddress
C parm bccAddress
C parm subject
C parm body
//*************************************************************************
/free
SendEmail(fromAddress:
toAddress:
ccAddress:
bccAddress:
subject:
body);
*INLR = *On;
/end-free
P*--------------------------------------------------
P* Procedure name: SendEmail
P* Purpose: Send Email at Real-Time
P* Returns: Was the Email Successful?
P* Parameter: fromAddress
P* Parameter: toAddress
P* Parameter: ccAddress
P* Parameter: subject
P* Parameter: body
P*--------------------------------------------------
P SendEmail B EXPORT
D SendEmail PI N
D fromAddress 100A CONST
D toAddress 32767A CONST
D ccAddress 32767A CONST
D bccAddress 32767A CONST
D subject 32767A CONST
D body 32767A CONST
D* Local fields
D dim S 3P 0
D emailArray DS
D email 100A DIM(327)
/free
// Setup the JVM
monitor;
RPGMail_init();
on-error;
rpgMailError = Error_catch();
if rpgMailError.code <> 'CPFA980';
return *OFF;
endif;
endmon;
monitor;
// Create a new object
rpgMailObject = RPGMail_new();
// From Address
RPGMail_addAddress(rpgMailObject:'FROM':
%trim(fromAddress):' ');
// To address
emailArray = ParseEmailAddresses(toAddress);
dim = 1;
dow email(dim) <> ' ';
RPGMail_addAddress(rpgMailObject:'TO':
%trim(email(dim)):' ');
dim += 1;
enddo;
// Carbon Copy
if ccAddress <> ' ';
emailArray = ParseEmailAddresses(ccAddress);
dim = 1;
dow email(dim) <> ' ';
RPGMail_addAddress(rpgMailObject:'CC':
%trim(email(dim)):' ');
dim += 1;
enddo;
endif;
// Blind Carbon Copy
if bccAddress <> ' ';
emailArray = ParseEmailAddresses(bccAddress);
dim = 1;
dow email(dim) <> ' ';
RPGMail_addAddress(rpgMailObject:'BCC':
%trim(email(dim)):' ');
dim += 1;
enddo;
endif;
// Subject
RPGMail_setSubject(rpgMailObject:%trim(subject));
// Email Body
RPGMail_setBodyText(rpgMailObject:%trim(body):'text/plain');
// Set the SMTP server information
RPGMail_setSMTPHost(rpgMailObject:'192.168.50.250');
RPGMail_setSMTPPort(rpgMailObject:'25');
// Send the Email
RPGMail_send(rpgMailObject);
on-error;
rpgMailError = Error_catch();
return *OFF;
endmon;
return *ON;
/end-free
P SendEmail
On 6/19/07, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:
Please post the variable definitions for your *ENTRY PLIST parameters?
Also, how is this command being called?
Mike wrote:
> They do:
>
> CMD PROMPT(CMD)
> PARM KWD(FROM) TYPE(*CHAR) LEN(100) MIN(1)
PROMPT('From
> Address: ')
> PARM KWD(TO) TYPE(*CHAR) LEN(32767) MIN(1) PROMPT('To
> Address:')
> PARM KWD(CC) TYPE(*CHAR) LEN(32767) PROMPT('CC
Address:')
> PARM KWD(BCC) TYPE(*CHAR) LEN(32767) PROMPT('BCC
> Address:')
> PARM KWD(SUBJECT) TYPE(*CHAR) LEN(32767) MIN(1)
> PROMPT('Subject:')
> PARM KWD(MESSAGE) TYPE(*CHAR) LEN(32767) MIN(1)
> PROMPT('Message:')
>
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.