Partner400 Logo
    RPGMail
   

This is the version of the RPGMail routine published in the October 2004 issue of the eServer magazine, iSeries edition. For a freeform version click here.

  All About Us

  Where To See Us

  Magazine Articles

  Downloads

  Rational RDi

  On-site Training

  The RPG Redbook

  Home Page

 

 

 

 

 

 

 

 

 

 



      //*********************************************************************
//
// Send Invoice via Email (c)Copyright Partner400, 2004.
//
// This sample program is provided for illustration purposes only and
// is provided "AS IS". The implied warranties of merchantability and
// fitness for a particular purpose are expressly disclaimed.
//
// Before you can compile and run this program, you will need to:
// a) Download and install the MMAIL utility
// - download at www-922.ibm.com
//
// b) Create the CSTMAST file.
// - It must contain at least the following fields:
//
// CUSTNO CHAR 6 Customer Number
// CONTACT CHAR 15 Contact Name
// EMAIL CHAR 50 E-Mail Address
//
//*********************************************************************

/copy MMAIL/qrpglesrc,hspecsbnd
H DftActGrp(*No) Option(*SrcStmt : *NoDebugIO)

FCstMast IF E K Disk
/copy MMAIL/qrpglesrc,mailproto

D FromName S 50A Inz('Susan Gantner')
D FromEmail S 50A Inz('Contact@partner400.com')
D SenderEmail S 255A Inz('Contact@partner400.com')
D EmailTemplate s 512A Inz('/Partner400/invMime.txt')
D InvPDFFile S 512A

D ToNameArr S 50A dim(1000)
D ToAddrArr S 256A dim(1000)
D ToDistArr S 10I 0 dim(1000)
D ContType S 21A Inz('application/pdf')
D BinFlag S 1A Inz('Y')
D ImbAtt S 10I 0 Inz(2)

D TempFile s 512A
D Error s 7A

D Reply S 1

D TxtVarArr s 10A DIM(500)
D TxtValArr s 500A DIM(500)

D Today S D

D SndInv PR ExtPgm('SNDINV')
D InvPDF 25A Const
D Customer Like(CustNo)

D SndInv PI
D InvPDF 25A Const
D Customer Like(CustNo)
*=====================================================================
* Main line
*=====================================================================
C Eval InvPDFFile = InvPDF
C Customer Chain(E) CstMast
C If Not %Error and %Found(CstMast)

C If Email <> ' '

// Create email Temporary file in the IFS for the note

C Eval TempFile = TempCrtF()

// Add Sender info to the email - includes date and time

C CallP MimeSender(TempFile : FromName : FromEmail)

// Receiver name and email from CstMast record added to 1st element of Array

C Eval ToNameArr(1)=Contact
C Eval ToAddrArr(1)=Email
C Eval ToDistArr(1)=0

// Add Receiver info to email Temporary File

C CallP MimeDistr(TempFile : ToNameArr:
C ToAddrArr : ToDistArr)

// Substituation values replace variabls in template file

C Eval TxtVarArr(1) = '&Name'
C Eval TxtVarArr(2) = '&Date'
C Eval TxtValArr(1) = Contact
C Time Today
C Eval TxtValArr(2) = %Char(Today)

C CallP MimeUpdTxt(TempFile : EmailTemplate:
C TxtVarArr : TxtValArr)

// Attach PDF (name from parm) to email

C CallP MimeImbAtt(TempFile : InvPDFFile :
C ContType : BinFlag : ImbAtt)

C CallP MimeClose(TempFile)


// Send the email. If errors occur, field Error will contain CPF message

C Eval Error = SendMail(TempFile :
C SenderEmail : ToAddrArr : ToDistArr)
C EndIf

C EndIf

C If Error <> ' '
C Error Dsply Reply
C Else
C 'Sent' Dsply Reply
C EndIf

C Eval *INLR = *On
C Return

     
Return to Home Page  

Want more information?
Got a question or comment about the site?
Please feel free to Contact Us at any time.}