Beruflich Dokumente
Kultur Dokumente
*
*
*
*
*
Modification Log
*
*----------------------------------------------------------------------*
* 03/10/2004 | Raymond Everhart | 000 | Program Created
*
*
|
|
|
*
*
|
|
|
*
*
|
|
|
*
*
|
|
|
*
************************************************************************
*
*
D* Prototype used by QTMMSENDMAIL API
D SndEmail
PR
Extproc('QtmmSendMail')
D IFSFile
* value
D FNameLen
10i 0
D Sender
* value
D SenderLen
10i 0
D RecipTbl
* value
D NbrRecips
10i 0
D pErr
* value
* copy error structure from QSYSINC
D/copy qsysinc/qrpglesrc,qusec
D Qdata
17
216
D
* set pointer to Error structure
D pErr
S
*
D
* email variables
D Cmd
S
256a
D CmdLen
S
15 5
D RecipTbl
S
32767a
D IFSFile
S
255a
D inetAddr
S
256a
D FNameLen
S
10i 0
D ListPtr
S
*
D Sender
S
256a
D SenderLen
S
10i 0
D NbrRecips
S
10i 0
D Text
S
80
D ToAddr
S
Inz(%addr(QUSEC))
Inz('/email/mimefile.txt')
Inz(%Addr(RecipTbl))
Like(iNetAddr)
From
To
CC
BC
Quote
C
C
C
C
C
Const('errors@morningstarfoods.com')
Const('AllCustomers@Lab400.com')
Const('CarbonCopy@Lab400.com')
Const('BlindCopy@Lab400.com')
Const('''')
Eval
BuildFile
SendTo
SendCC
SendBC
SendFrom
Header
Body
Footer
Move2IFS
SendEmail
*INLR = *On
**************************************************************************
/Eject
**************************************************************************
C
*Inzsr
Begsr
C
Eval
FNameLen = %Len(%Trim(IFSFile))
Endsr
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Write the email Body lines from the Mailform File
* (Notice how much easier it is to code these statements in Free Format RP
G)
*
/FREE
Begsr Body;
// First Row
Text = '<TR><TD ALIGN="Left">M465043</TD>';
Exsr WriteText;
Text = '<TD ALIGN="Left">Roys Sandwich Shoppe</TD>';
Exsr WriteText;
Text = '<TD ALIGN="Right">03/15/2004</TD>';
Exsr WriteText;
Text = '<TD ALIGN="Right">1,245.55</TD></TR>';
Exsr WriteText;
// Second Row
Text = '<TR><TD ALIGN="Left">M464657</TD>';
Exsr
Text
Exsr
Text
Exsr
Text
Exsr
WriteText;
= '<TD ALIGN="Left">That Sub Place</TD>';
WriteText;
= '<TD ALIGN="Right">03/19/2004</TD>';
WriteText;
= '<TD ALIGN="Right">1,455.85</TD></TR>';
WriteText;
// Third Row
Text = '<TR><TD ALIGN="Left">M557890</TD>';
Exsr WriteText;
Text = '<TD ALIGN="Left">Harrys House of Hoagies</TD>';
Exsr WriteText;
Text = '<TD ALIGN="Right">03/22/2004</TD>';
Exsr WriteText;
Text = '<TD ALIGN="Right">6,685.55</TD></TR>';
Exsr WriteText;
EndSr;
/END-FREE
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Build a file in QTEMP to format the email message
*
C
BuildFile
Begsr
*
C* Create an Empty WorkFile
C/Exec SQL
C+ Create table QTEMP/EMAIL
C+ (TEXT CHAR (80 ) NOT NULL WITH DEFAULT)
C/End-Exec
* Delete any records left in file from a previous run
C/Exec SQL
C+ Delete from QTEMP/EMAIL
C/End-Exec
C
EndSr
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Write Out Email Footer
*
C
Footer
Begsr
* Write the end tag for the table
Eval
Text = '</TABLE>'
Exsr
WriteText
C
C
C
C
OF
REPORT'
C
C
Eval
Exsr
EndSr
Text = '</body></HTML>'
WriteText
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Write the Header lines
*
C
Header
Begsr
* Write the From Address
Eval
C
C
C
C
Exsr
* Write the To Address
Eval
C
C
C
C
Exsr
* Write the Subject Line
Eval
C
C
C
Exsr
C
C
C
C
C
C
C
C
C
Exsr
* Write a blank Line
Eval
Exsr
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
Exsr
Eval
Exsr
Eval
Exsr
Eval
Exsr
Eval
Exsr
'/graphics/'
WriteText
Text = 'iseries_family.jpg">'
WriteText
Text = '</td><td><FONT SIZE=5>'
WriteText
Text ='HTML formatted Email <br>' +
'from the iSeries'
WriteText
Text ='</font></td></tr></table><br>'
WriteText
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
align="center">'
align="center">'
align="center">'
align="center">'
EndSr
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Move the file to the IFS and change the user authority to the file
*
*
C
Move2IFS
Begsr
C
C
C
C
C
C
C
C
C
C
C
Eval
Call
Parm
Parm
'QCMDEXC'
C
C
C
C
C
C
Eval
Eval
Eval
CmdLen = %Len(%Trim(Cmd))
C
C
C
C
Call
Parm
Parm
EndSr
'QCMDEXC'
Cmd
CmdLen
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Retreive the Blind Copy (BC) addresses from the Mailform File
*
*
C
SendBC
Begsr
C* load recipients into table (blind copy)
C
C
C
C
C
C
C
Eval
Eval
Eval
Eval
Eval
Eval
Eval
* Move the DS Pointer
Eval
C
C
DistType = 2
DestAddr = BC
Addrfmt = 'ADDT0100'
Resrvd01 = 0
Addrlen = %len(%trim(DestAddr))
NextOffset = 24 + Addrlen
NbrRecips = NbrRecips + 1
ListPtr = ListPtr + NextOffset
EndSr
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Retreive the Carbon Copy (CC) addresses from the Mailform File
*
*
C
SendCC
Begsr
C* load recipients into table (carbon copy)
C
C
C
C
C
C
C
Eval
Eval
Eval
Eval
Eval
Eval
Eval
* Move the DS Pointer
Eval
C
C
DistType = 1
DestAddr = CC
Addrfmt = 'ADDT0100'
Resrvd01 = 0
Addrlen = %len(%trim(DestAddr))
NextOffset = 24 + Addrlen
NbrRecips = NbrRecips + 1
ListPtr = ListPtr + NextOffset
EndSr
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Retreive the From address from the Mailform File
*
*
C
SendFrom
Begsr
C* load from address into table
C
C
Eval
Eval
EndSr
Sender = From
SenderLen = %len(%trim(Sender))
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Retreive the Send To address from the Mailform File
*
*
C
SendTo
Begsr
C* load first recipient into table
C
C
C
C
C
C
C
Eval
Eval
Eval
Eval
Eval
Eval
Eval
* Move the DS Pointer
Eval
C
C
DistType = 0
DestAddr = To
Addrfmt = 'ADDT0100'
Resrvd01 = 0
Addrlen = %len(%trim(DestAddr))
NextOffset = 24 + Addrlen
NbrRecips = 1
ListPtr = ListPtr + NextOffset
EndSr
**************************************************************************
********************
C/Eject
**************************************************************************
********************
* Send the email via the API. When the API completes normally, the IFS fi
le is deleted.
C
SendEmail
Begsr
Callp
SndEmail(%addr(IFSFile):
FNameLen:
%addr(Sender):
SenderLen:
%addr(RecipTbl):
C
Number of Recipients
C
Error Structure
C
NbrRecips:
pErr)
EndSr
**************************************************************************
/Eject
**************************************************************************
*
C
WriteText
Begsr
C/Exec SQL
C+ Insert into Qtemp/EMAIL
C+ VALUES(:Text)
C/End-Exec
C
EndSr