sponsored links

Collapse

Announcement

Collapse
No announcement yet.

How to send a mail to more than one Recipient (sendmail_h ) CC:

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to send a mail to more than one Recipient (sendmail_h ) CC:

    Hi Everyone,
    I just using sendmail_h with QtmmSendMail API to send an attachment to one recipient wihout problem. But know i need to send the information to more than one recipient (CC But i don't know the correct way to do it.
    Could somebody has an example to learn how to do it?


    Example : (Just one RECIPIENT but I need 3 mail more as a CC)
    PHP Code:
    recip(1).NextOffset = %size(ADDTO0100);
    recip(1).AddrFormat 'ADDR0100';
    recip(1).DistType ADDR_NORMAL;
    recip(1).Reserved 0;
    recip(1).SmtpAddr toAddr;
    recip(1).AddrLen = %len(toAddr);

    QtmmSendMailFileName
    : %len(FileName)
    fromAddr
    : %len(fromAddr)
    recip
    : %elem(recip)
    NullError ); 
    Hope somebody could help.

    Best Regards,
    Last edited by jamief; 1 day ago.

  • #2
    Try this:
    http://www.code400.com/forum/forum/i...mmsendmail-api

    Comment


    • #3
      wow -- who posted that old code

      Take a peek @ SNDSMTPEMM
      PHP Code:
           H NOMAIN EXPROPTS(*RESDECPOS)                                                                  
           
      H AlwNull(*UsrCtl)                                                                             
            
      //********************************************************************                        
            // Program Name -- SNDEMAIL                                                                   
            // Written By   -- J.J.F.     Date Written  -- 12/01/2017                                     
            // Modified By  -- X.X.X.     Last Revision -- XX/XX/XXXX                                     
            //********************************************************************                        
            // List all modifications to this program below in the                                        
            // format of initials, date & description of your change.                                     
            // Initials    Date    Description                                                            
            //  J.J.F.   08/11/16  Procedures                                                             
            //********************************************************************                        
            //                  *-* Module Description *-*                                                
            //                                                                                            
            // send emails with/without attachemnts                                                       
            //                                                                                            
            //********************************************************************                        
            //==============================================================*                             
            //        DATA SPECIFICATIONS                                   *                             
            //--------------------------------------------------------------*                             
            // -------------------- Data Structures --------------------                                  
            // ------------------ Standalone Variables -----------------                                  
           
      d attach          s               n   inz('0')                                                 
           
      d count           s             10  0 inz                                                      
           d defaultUser     s             10    inz                                                      
           d IHaveAnError    s               n   inz
      ('0')                                                 
           
      d MaxDataStructureCount...                                                                     
           
      d                 s             10i 0 inz                                                      
           d Q               s              1    inz
      ('''')                                                
            
      // ---------------------- Data Structures ------------------                                  
            
      *-----------------------------------------------------------------                            
            * 
      program status dataarea                                                                     
            
      *-----------------------------------------------------------------                            
           
      d PgmSts         SDS                                                                           
           d   P1User              254    263                                                             
           d   
      @PGM            *PROC                                                                      
           d   
      @JOB                244    253                                                             
            
      //==============================================================*                             
            //   PROTOTYPES                                                 *                             
            //--------------------------------------------------------------*                             
            
      /copy qprcsrc,SDEMAIL_CP                                                                      
            
      /copy qprcsrc,COMMAND_CP                                                                      
            
      //==============================================================*                             
            //              PROCEDURE INTERFACE                             *                             
            //--------------------------------------------------------------*                             
           
      pSendEmail        b                   export                                                   
           d SendEmail       pi              n                                                            
           d Inparms                     5050                                                             
            
      /Free                                                                                         
            
      //=============================================================*                              
            //             M A I N L I N E                                 *                              
            //-------------------------------------------------------------*                              
               
      *inlr = *on;                                                                               
               
      mydata.allmydata InParms;                                                                
               
      reset Attach;                                                                              
               
      // How many emails do I have?                                                              
               // SNDSMTPEMM                                                                              
               // RCP((JAMIEf@rockfordBallScrew.COM)                                                      
               //     (someoneElse@RockfordBallScrew.COM *CC))                                            
               // SUBJECT('this is testing SNDSMTPEMM')                                                   
               // NOTE('This is a note')                                                                  
               // ATTACH(('/home/jamie/myfile.csv' *EXCEL)                                                
               //        (DELETEDCUSTOMER.ZIP *ZIP)                                                       
               //        ('20160525_143559.jpg' *JPEG))                                                   
               // CONTENT(*HTML)                                                                          
               
      if  mydata.emailaddresses.address(1) = *blanks;                                            
                
      IHaveAnError = *on;                                                                       
               endif;                                                                                     
               
      OneThousandLong =                                                                          
               
      'SNDSMTPEMM RCP(';                                                                         
               for 
      count 1 to 20;                                                                       
                if 
      mydata.emailaddresses.address(count) <> *blanks;                                       
                
      OneThousandLong = %trim(OneThousandLong) +                                                
                 
      '(' + %trim(mydata.emailaddresses.address(count)) + ')';                                 
                endif;                                                                                    
               endfor;                                                                                    
                
      OneThousandLong = %trim(OneThousandLong) +                                                
               
      ') SUBJECT(' + %trim(mydata.subject) + ') ' +                                      
               
      ' NOTE(' Q  + %trim(mydata.body) + +  ') ' ;                                           
               for 
      count 1 to 10;                                                                       
                if 
      mydata.attachments.fullpath(count) <> *blanks;                                         
                if 
      attach = *off;                                                                         
                 
      OneThousandLong = %trim(OneThousandLong) +  ' ATTACH(';                                  
                 
      attach = *on;                                                                            
                endif;                                                                                    
                
      OneThousandLong = %trim(OneThousandLong) +                                                
                
      '(' + %trim(mydata.attachments.fullpath(count)) + Q+                                  
                
      '   ' + %trim(mydata.attachments.type(count)) + ')';                                      
                endif;                                                                                    
               endfor;                                                                                    
               
      // if mydata.attachments.fullpath(1) <> *blanks;                                           
               
      if attach = *on;                                                                           
                
      OneThousandLong = %trim(OneThousandLong) + ')';                                           
               endif;                                                                                     
               
      OneThousandLong = %trim(OneThousandLong) +                                                 
               
      ' CONTENT(*HTML)';                                                                         
               
      monitor;                                                                                   
                
      runcommand(OneThousandLong);                                                              
               
      on-error;                                                                                  
                
      IHaveAnError = *on;                                                                       
               
      endmon;                                                                                    
               Return 
      IhaveAnError;                                                                       
            /
      End-Free                                                                                     
           PSendEmail        e 

      Here is an example of how I used it -- This example is used to read a dataq attached to an outq and convert green screen reports to .PDF and email back to the user

      PHP Code:
           H DFTACTGRP(*NOOPTION(*SRCSTMT: *NODEBUGIOBNDDIR('UTILITIES')                              
           
      *******************************************************************************************   
           
      *  Program:    EMAILPDF                                                                   *   
           
      *  Desc:       Convert Spooled file to PDF and email back to user                         *   
           
      *                                                                                         *   
           
      *    Date      Who  What                                                                  *   
           
      *  ----------  ---  ----                                                                  *   
           
      *  12/15/2016  JJF  Program created                                                       *   
           
      *******************************************************************************************   
           
      f*usid      if   e           k disk    usropn                                                  

           d ccsid           s             10U 0 INZ
      (1252)                                                
           
      d Count           s             10i 0 inz                                                      
           d CRLF            c                   
      CONST(X'0d25')                                           
           
      d CurrentUser     s             10    inz                                                      
           d Decimal6        s              6  0 inz                                                      
           d DefaultEmail    s            100    inz
      ('jamieF@someplace.com')                      
           
      d ErrorReturned   s               n   inz                                                      
           d FMTNM           s              8a                                                            
           d Inuser          s             10                                                             
           d Inapplication   s             20                                                             
           d Insubject       s             80                                                             
           d Inmessage       s            512                                                             
           d INTJOB          s             16a                                                            
           d INTSPL          s             16a                                                            
           d KeepLooping     s               n   inz
      ('1')                                                 
           
      d MyTableName     s             36    inz                                                      
           d SpoolFound      s               n   inz
      ('0')                                                 
           
      d SpoolNumber     s              6a   inz                                                      
           d today           s               d   datfmt
      (*isoinz                                         
           d Usrdta          s             10a   inz                                                      

           d SpoolInfo       ds                                                                           
           d  
      Function                     10                                                             
           d  RecordType                    2                                                             
           d  QualJobName                  26                                                             
           d   JobName                     10     Overlay
      (QualJobName:1)                                  
           
      d   JobUser                     10     Overlay(QualJobName:11)                                 
           
      d   JobNumber                    6     Overlay(QualJobName:21)                                 
           
      d  FileName                     10                                                             
           d  FileNumber                   10i 0                                                          
           d  QualQueueName                20                                                             
           d   QueueName                   10     Overlay
      (QualQueueName:1)                                
           
      d   QueueLibrary                10     Overlay(QualQueueName:11)                               
           
      d  Filler                       56                                                             

           d $ReadDataq      pr                  extpgm
      ('QRCVDTAQ')                                       
           
      d  queuename_                   10    const                                                    
           
      d  queuelibrary_                10    const                                                    
           
      d  queuesize_                    5  0 const                                                    
           
      d  queuemessage_               128    const                                                    
           
      d  queuewait_                    5  0 const                                                    

            /
      copy qprcsrc,COMMAND_CP                                                                      
            
      /copy qprcsrc,GETGUID_CP                                                                      
            
      /copy qprcsrc,GETEMLA_CP                                                                      
            
      /copy qprcsrc,GETUSDD_CP                                                                      
            
      /copy qprcsrc,SDEMAIL_CP                                                                      
            
      /copy qprcsrc,SPL2PDF_CP                                                                      


            
      /free                                                                                         
                  
      *inlr = *on;                                                                            
                  
      exsr $ProcessDataQueue;                                                                 
             
      //--------------------------------------------------------                                   
             // loop forever looking for spooled files to convert                                         
             //--------------------------------------------------------                                   
             
      begsr $ProcessDataQueue;                                                                     
              
      dow KeepLooping;                                                                            
               
      $ReadDataq('EMAILPDF':'*LIBL':128SpoolInfo: -1);                                         
               
      Decimal6 = %dec(FileNumber:6:0);                                                           
               
      SpoolNumber = %editc(Decimal6:'X');                                                        
               
      // get the PDF name                                                                        
               
      MyTableName GetGuid();                                                                   
               
      // set the path and name of document                                                       
               
      FullPathToPDF '/tmp/' +%trim(MyTableName) + '.pdf';                                      
               
      // new spooled file has arrived                                                            
               
      ErrorReturned =                                                                            
               
      SpoolToPDF(FileName:Jobnumber:JobUser:JobName:                                             
               
      SpoolNumber:FullPathtoPDF:QueueName);                                                      
               if 
      not(ErrorReturned);                                                                     
                
      exsr $sendTHeEmail;                                                                       
                
      // delete the spooled file                                                                
                // DLTSPLF FILE(EMAILPDF) JOB(588743/MSFLANARY/QPADEV0003) SPLNBR(*LAST)                  
                
      OneThousandLong =                                                                         
                 
      'DLTSPLF FILE(' + %trim(filename) + ') JOB('  +                                          
                 %
      trim(JobNumber) + '/' + %trim(JobUser) + '/' +                                          
                 %
      trim(JobNAME) + ') SPLNBR(*LAST)';                                                      
                
      monitor;                                                                                  
                 
      runcommand(OneThousandLong);                                                             
                
      on-error;                                                                                 
                
      endmon;                                                                                   
               endif;                                                                                     
              
      enddo;                                                                                      
             
      endsr;                                                                                       
             
      //--------------------------------------------------------                                   
             // send the report out via email                                                             
             //--------------------------------------------------------                                   
             
      begsr $SendTheEmail;                                                                         

               
      // get email address                                                                       
               
      defaultemail GetEmailAddress(Jobuser);                                                   
               if 
      defaultemail = *blanks;                                                                 
                
      reset defaultemail;                                                                       
               endif;                                                                                     

              
      // possible 20 email addresses -- unsure of default email (correct later)                   
              
      mydata.emailaddresses.address(1) =  %trim(defaultemail);                                    
              
      mydata.emailaddresses.type(1) = '*PRI';                                                     
              
      // possible 10 attachments (see procedure for full list of types)                           
              
      mydata.attachments.fullpath(1) = %trim(FullPathToPDF);                                      
              
      mydata.attachments.type(1) = '*PDF';                                                        
              
      mydata.subject  'RBS Auto Report Distribution';                                           
              
      mydata.body   =                                                                             
               
      'Please review attached document.';                                                        
               
      sendemail(Mydata.allmydata);                                                               
             
      endsr;                                                                                       
            /
      end-free 
      I attached the code


      Attached Files
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment

      sponsored links

      Collapse

      Working...
      X