Академический Документы
Профессиональный Документы
Культура Документы
*
* To compile:
*
*
*
CRTRPGMOD MODULE(QTEMP/HTMLONLY) +
SRCFILE(xxx/QRPGLESRC) +
DBGVIEW(*LIST)
*
*
*
CRTPGM PGM(&mylib/HTMLmail) +
MODULE(&mylib/HTMLmail) +
BNDSRVPGM(QTCP/QTMMSNDM)
*
*
H BNDDIR('QC2LE') OPTION(*SRCSTMT:*NOSHOWCPY)
fworkfile if
k disk
*-------------------------------------------------------------------* Remove Link to File. (Deletes Directory Entry for File, and if
*
this was the last link to the file data, the file itself is
also deleted)
*
* int unlink(const char *path)
*-------------------------------------------------------------------D unlink
D
path
PR
10I 0 ExtProc('unlink')
*
Value options(*string)
PR
D fildes
10I 0 ExtProc('write')
10i 0 value
D buf
D bytes
value
10U 0 value
PR
D path
10I 0 ExtProc('open')
*
value options(*string)
D openflags
10I 0 value
D mode
D ccsid
D/if defined(*V5R2M0)
D txtcreatid
D/endif
*-------------------------------------------------------------------* Close a file
*
* int close(int fildes)
*
* Note: Because the same close() API is used for IFS, sockets,
*
*-------------------------------------------------------------------D close
PR
10I 0 ExtProc('close')
D fildes
10I 0 value
*-------------------------------------------------------------------d QtmmSendMail
d
FileName
FileNameLen
MsgFrom
MsgFromLen
RecipBuf
PR
ExtProc('QtmmSendMail')
255A
const options(*varsize)
10I 0 const
256A
const options(*varsize)
10I 0 const
likeds(ADDTO0100)
dim(32767)
options(*varsize)
NumRecips
ErrorCode
d ADDTO0100
10I 0 const
8000A
ds
options(*varsize)
qualified
based(Template)
NextOffset
10I 0
AddrLen
10I 0
AddrFormat
DistType
10I 0
Reserved
10I 0
SmtpAddr
8A
256A
d ADDR_NORMAL
CONST(0)
d ADDR_CC
CONST(1)
d ADDR_BCC
CONST(2)
D tmpnam
PR
string
*
39A
D MailDate
PR
D CRLF
D filename
50A
D fd
10I 0
extproc('_C_IFS_tmpnam')
options(*omit)
31A
x'0d25'
varying
D header
2000A
varying
D body
32767A
varying
D fromName
100A
varying
D fromAddr
300A
varying
D M_RDWR
const(438)
**********************************************************************
* Flags for use in open()
*
* More than one can be used -- add them together.
**********************************************************************
D O_RDONLY
D O_WRONLY
D O_RDWR
D O_CREAT
D O_EXCL
16
D O_CCSID
32
D O_TEXTDATA
16777216
D O_CODEPAGE
8388608
D O_TEXT_CREAT
33554432
D O_INHERITMODE
134217728
D O_LARGEFILE
536870912
D toName
100A
varying
D toAddr
300A
varying
D subject
80A
varying
D recip
ds
likeds(ADDTO0100)
dim(1)
D NullError
ds
BytesProv
10I 0 inz(0)
BytesAvail
10I 0 inz(0)
D wait
1A
/free
fromName = 'SomeOne';
fromAddr = 'jimmyoctane@code400.com';
toName
= 'testname';
toAddr
= 'jflanary@somedomain.com';
endif;
// -----------------------------------------// build an e-mail header in a variable
// -----------------------------------------header =
'From: ' + fromName + ' <' + fromAddr + '>' + CRLF
+'To: '
+ toName
+ '>' + CRLF
+'
font-size: 14pt;'
+'
+ CRLF
+'</style>' + CRLF
+'</head>' + CRLF
+'<body>'
+ CRLF
read workfile;
dow not%eof(workfile);
body = %trim(body) + '<li> ' + ' <b>' +
%trim(claim) + '</b> : ' + %editc(amount:'J') + '<BR><BR>'
+ CRLF;
read workfile;
enddo;
body = %trim(body)
+'</ul></td>' + CRLF
+ ' <A href="mailto:jflanary@somedomain.com">Comments</A>'
+'</body>' + CRLF
+'</html>' + CRLF;
// -----------------------------------------// write the data to the IFS file
// (since the file is in text mode, it'll
//
= ADDR_NORMAL;
recip(1).Reserved
= 0;
recip(1).SmtpAddr
= toAddr;
recip(1).AddrLen
= %len(toAddr);
QtmmSendMail( FileName
: %len(FileName)
: fromAddr
: %len(fromAddr)
: recip
: %elem(recip)
: NullError );
*inlr = *on;
/end-free
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* MailDate(): Returns the current date, formatted for use
*
in an e-mail message.
*
*
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P MailDate
D MailDate
PI
D CEELOCT
PR
31A
opdesc
Lilian
10I 0
Seconds
8F
Gregorian
23A
fc
12A
D CEEUTCO
PR
opdesc
Hours
10I 0
Minutes
10I 0
Seconds
8F
fc
D CEEDATM
options(*omit)
12A
PR
options(*omit)
opdesc
input_secs
8F
date_format
80A
const options(*varsize)
char_date
80A
options(*varsize)
feedback
12A
options(*omit)
D rfc2822
D junk1
8F
D junk2
10I 0
D junk3
23A
D hours
10I 0
D mins
10I 0
D tz_hours
2P 0
D tz_mins
2P 0
D tz
5A
D CurTime
8F
D Temp
25A
/free
const
varying
//
// Calculate the Timezone in format '+0000', for example
//
tz += %editc(tz_hours:'X') + %editc(tz_mins:'X');
//
// Get the current time and convert it to the format
//
//
CEELOCT(junk2: CurTime: junk3: *omit);
CEEDATM(CurTime: rfc2822: Temp: *omit);
return Temp + ' ' + tz;
/end-free