ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Emailing from AS400 with RPG using MMAIL V6R1

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

  • Emailing from AS400 with RPG using MMAIL V6R1

    Sorry I'm not sure this is where to post this question but I'm hoping someone can help. We are currently setting up a AS400 new box with V6R1 but haven't gone live with it yet as I'm still testing.
    My problem is I downloaded the latest and greatest version of MMAIL on it but some of the commands have changed. Formerly we used this command:

    Code:
    EVAL      cmd_str = 'EMLSPL SUBJECT(''' +
         C*                             %trim(SUBJECT) + ''') ' +
         C*                             'FROMNAME(''' + %trim(SenderName) +
         C*                             ''') FROMADDR(' + %trim(SenderAddr)       +
         C*                             ') TONAME(''' + %trim(TONAME) +
         C*                             ''') TOADDR(' + %trim(TOEMAIL) +
         C*                             ') FILE(' + wSPLFName +
         C*                             ') JOB(' + %trim(wJobNumber) +
         C*                             '/' + %trim(wUserName) +
         C*                             '/' + %trim(wJobName) +
         C*                             ') SPLNBR(' +
         C*                             %trim(wSPLFNbr) +
         C*                             ')' + ' CVTPDF(*YES) +
         C*                             EDTMBR(*NO) +
         C*                             TXTF(AIMDATA/QTXTSRC) +
         C*                             TXTMBR(DFTMSGESPL)'
    Any way the new MMAIL's code has changed I do know that all the TO information is no longer seperate but all in one and so is the SPLF information. The problem is I can't quite figure out how to do it. Here was my latest try:


    Code:
    EVAL      cmd_str = 'EMLSPL +
         C                             SUBJECT(''' + %trim(SUBJECT) +
         C                             ''') FROMNAME(''' + %trim(SenderName) +
         C                             ''') FROMADDR(' + %trim(SenderAddr) +
         C                             ') TO = (toemail: +
         C                               toname: +
         C                              *TO) SPLF = (*YES: +
         C                               wSPLFNbr: +
         C                               wusername: +
         C                               wjobname: +
         C                               wJobNumber: +
         C                               wSPLFName)'

    What we are doing is calling a physical file that has all the email information and the names of the reports and queues and so forth. I know there were issues with converting to PDF in V6R1 but when I go to the MAIL menu and do this manually everything works great. It's something to do with my code I believe. From the command line this works great.

    EMLSPL SUBJECT('t') FROMNAME('l') FROMADDR('email@address.com') TO('email@address.com'/'l'/*TO) SPLF(*YES/1/007556/SECOFR/DSP01002/DUMMYREPORT)

    I've looked all over the MMAIL website and all I found was this:


    Code:
    MMAIL/EMLSPL SUBJECT('Daily sales report')
    FROMNAME('John Evans') FROMADDR('jevans@mail.com')
    TO('dooley@superstar.com'/'Tom Dooley'/*TO)
    SPLF(*YES/*LAST/*N/*N/*CURRENT/QSYSPRT)
    Has anyone else come across this problem? I would appreciate any help.
    Stand up for what you beleive in ...... even if you are standing alone

  • #2
    Re: Emailing from AS400 with RPG using MMAIL V6R1

    here's one i have working
    Code:
    CmdStr ='EMLSPL SUBJECT(''PM Report'') FROMNAME(''DBS'') ' + 
       'FROMADDR(''DBS@test.COM'') ';               
    CmdStr += 'TO(''Keith@test.com''/Keith' + 
       '/*TO ''Sidxxx@test.com''/Sid/*TO ' +    
       '''Jeremyxxx@test.com''/Jeremy/*TO ' +   
       '''Caseyxxx@test.com''/Casey/*TO ' +    
       ') SPLF(*YES/*LAST/*N/*N/*CURRENT/QSYSPRT) ';
    you can combine those into a single statement but in the program there's conditional logic i removed and am too lazy to combine the 2 statements
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Emailing from AS400 with RPG using MMAIL V6R1

      by the way it is your code that's wrong...the use of colons in particular
      Code:
           C               EVAL      cmd_str = 'EMLSPL +
           C                             SUBJECT(''' + %trim(SUBJECT) +
           C                             ''') FROMNAME(''' + %trim(SenderName) +
           C                             ''') FROMADDR(' + %trim(SenderAddr) +
           C                             ') TO = (toemail: +
           C                               toname: +
           C                              *TO) SPLF = (*YES: +
           C                               wSPLFNbr: +
           C                               wusername: +
           C                               wjobname: +
           C                               wJobNumber: +
           C                               wSPLFName)'
      should be something like this:
      Code:
      EVAL      cmd_str = 'EMLSPL +
           C                             SUBJECT(''' + %trim(SUBJECT) +
           C                             ''') FROMNAME(''' + %trim(SenderName) +
           C                             ''') FROMADDR(' + %trim(SenderAddr) +
           C                             ') TO(' + %trim(toemail) + '/' +
           C                               %Trim(toname) + '/' +
           C                              '*TO) SPLF(*YES/' +
           C                               %Trim(wSPLFNbr) + '/' +
           C                               %Trim(wusername) + '/' +
           C                               %Trim(wjobname) + '/' +
           C                               %Trim(wJobNumber) + '/' +
           C                               %Trim(wSPLFName) + ')'
      well you get the idea...
      I'm not anti-social, I just don't like people -Tommy Holden

      Comment


      • #4
        Re: Emailing from AS400 with RPG using MMAIL V6R1

        Thank you so much I have been going round and round with this for a week or more. I don't know why I didn't post earlier. Thank you thank you thank you!!!!
        Stand up for what you beleive in ...... even if you are standing alone

        Comment


        • #5
          Re: Emailing from AS400 with RPG using MMAIL V6R1

          just for clarity's sake, the colon is used to separate parameters in procedures, values in BIFs, etc...not as variables in strings. the only time a colon is used in conjunction with a variable name is when using as a SQL host variable and then it's only within the SQL statement, outside of the statement it will still simply be referenced without the colon. for example:
          Code:
            myvar = 'MY VALUE';
            Exec SQL 
               Select * from myfile where myfield = :myvar;
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment


          • #6
            Re: Emailing from AS400 with RPG using MMAIL V6R1

            Ah thank you I appreciate the help. I've got this all but going with 1 issue with the SPLF part. If I hard code the details in of file I want it works great but as soon as I try to use my variables it blows up. Here's the code that works:

            Code:
             EVAL      cmd_str = 'EMLSPL +
                 C                             SUBJECT(''' + %Trim(Subject) + ''' +
                 C                             ) FROMNAME(''' + %Trim(SenderName) + ''') +
                 C                              FROMADDR(''' + %Trim(SenderAddr) + ''' +
                 C                              ) TO(''' + %Trim(ToEmail) + '''/+
                 C                               ''' + %Trim(ToName) + '''/*TO) +
                 C                               SPLF(*YES/+
                 C                               1/+
                 C                               008004/+
                 C                               SECOFR/+
                 C                               PMEXCEPT01/+
                 C                               PRTFILE)'
            But as soon as I try to put variables in,it blows up.

            Code:
            EVAL      cmd_str = 'EMLSPL +
                 C                             SUBJECT(''' + %Trim(Subject) + ''' +
                 C                             ) FROMNAME(''' + %Trim(SenderName) + ''') +
                 C                              FROMADDR(''' + %Trim(SenderAddr) + ''' +
                 C                              ) TO(''' + %Trim(ToEmail) + '''/+
                 C                               ''' + %Trim(ToName) + '''/*TO) +
                 C                               SPLF(*YES/+
                 C                               (wsplfnmbr)/+
                 C                               (wjobnumber)/+
                 C                               (wusername)/+
                 C                               (wjobname)/+
                 C                               (wsplfname))'
            I've tried putting quotes around them and all kinds of various ways but it just does not like them. Do you have any magic tricks left in your hat????
            Thanks
            Stand up for what you beleive in ...... even if you are standing alone

            Comment


            • #7
              Re: Emailing from AS400 with RPG using MMAIL V6R1

              take a good look at my previous post.
              1) you left of the BIF %TRIM() on the variables
              2) you are concatenating a string so you'll have to use quotes

              with your working example with hardcoded values the actual command produced is like this:
              Code:
              EMLSPL SUBJECT('Subject') 
              FROMNAME('SenderName')
              FROMADDR('SenderAddr@whatever.com')
              TO('whoever@whatever.com'/'whoever'/*TO)
              SPLF(*YES/1/008004/SECOFR/PMEXCEPT01/PRTFILE)
              the non-working code produces this:
              Code:
              EMLSPL SUBJECT('Subject')
              FROMNAME(''SenderName')
              FROMADDR('Sender@whatever.com')
              TO('whoever@whatever.com'/'whoever'/*TO)
              SPLF(*YES/(wsplfnmbr)/(wjobnumber)/(wusername)/(wjobname)/(wsplfname))
              do you see where the problem is?
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: Emailing from AS400 with RPG using MMAIL V6R1

                this should do it or be pretty darn close
                Code:
                c                   EVAL      cmd_str = 'EMLSPL '                      
                c                             + 'SUBJECT(''' + %Trim(Subject) + '''' + 
                C                             ') FROMNAME(''' + %Trim(SenderName)      
                c                             + ''') FROMADDR('''                      
                C                             + %Trim(SenderAddr)                      
                C                             + ''') TO(''' + %Trim(ToEmail) + '/' +   
                C                             + %Trim(ToName) + '/*TO)' +              
                C                             + ' SPLF(*YES/'                          
                C                             + %TrimR(wsplfnmbr) + '/' +              
                C                             + %TrimR(wjobnumber) + '/' +             
                C                             + %TrimR(wusername) + '/' +              
                C                             + %TrimR(wjobname) + '/' +               
                C                             %TrimR(wsplfname) + ')'
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: Emailing from AS400 with RPG using MMAIL V6R1

                  It worked!!!! I am so excited!! I had tried so many ways before and I even tried with the %trim and some quotes but I must have had something askew. You are so wonderful I have been working on this for over a week and it was driving me nuts. I should be smacked for not posting sooner. Thank you so much Tom. I should have known someone on this board would have the answer. Thank you thank you thank you!!!
                  Stand up for what you beleive in ...... even if you are standing alone

                  Comment


                  • #10
                    Re: Emailing from AS400 with RPG using MMAIL V6R1

                    We need to give Tom a raise.
                    Michael Catalani
                    IS Director, eCommerce & Web Development
                    Acceptance Insurance Corporation
                    www.AcceptanceInsurance.com
                    www.ProvatoSys.com

                    Comment


                    • #11
                      Re: Emailing from AS400 with RPG using MMAIL V6R1

                      He would be worth every penny....
                      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


                      • #12
                        Re: Emailing from AS400 with RPG using MMAIL V6R1

                        I'll agree with that, now if we can just get the big boss to acknowledge it LOL!
                        Stand up for what you beleive in ...... even if you are standing alone

                        Comment

                        Working...
                        X