bvstone

G4MSMAIL Updated to Allow Use Of Configuration Files and More

Posted:

G4MSMAIL Updated to Allow Use Of Configuration Files and More

New Configuration Files

As with MAILTOOL Plus, we have just updated G4MSMAIL so that you are able to use JSON configuration files to set the value of certain options that are static.

When the latest version of G4MS is installed you will get a new file in the IFS named:

/bvstools/g4ms/config/defaults.json

This file will contain all the available parameters that you can use.  Following is an example:

{
	"variables": [
	{
		"name":"id",
		"default":" "
	},
	{
		"name":"from",
		"default":" "
	},
	{
		"name":"from_name",
		"default":" "
	},
	{
		"name":"sender",
		"default":" "
	},
	{
		"name":"sender_name",
		"default":" "
	},
	{
		"name":"subject",
		"default":" "
	},
	{
		"name":"message",
		"default":" "
	}, 
	{
		"name":"message_stream_file",
		"default":" "
	},
	{
		"name":"parent_folder",
		"default":" "
	},
	{
		"name":"label_id",
		"default":" "
	},
	{
		"name":"message_id",
		"default":" "
	},
	{
		"name":"attachment_id",
		"default":" "
	},
	{
		"name":"attachment_name",
		"default":" "
	},
	{
		"name":"get_new_only",
		"default":"*YES"
	},
	{
		"name":"mark_as_read",
		"default":"*YES"
	},
	{
		"name":"move_to_folder",
		"default":" "
	},
	{
		"name":"max_part_size",
		"default":"16773104"
	},
	{
		"name":"get_parts",
		"default":" "
	},
	{
		"name":"message_content_type",
		"default":" "
	},
	{
		"name":"message_importance",
		"default":"Normal"
	},
	{
		"name":"deliver_receipt_requested",
		"default":"false"
	},
	{
		"name":"read_receipt_requested",
		"default":"false"
	},
	{
		"name":"save_to_sent_items",
		"default":"true"
	},
	{
		"name":"no_attachment_action",
		"default":" "
	},
	{
		"name":"temp_dir",
		"default":"/tmp"
	},
	{
		"name":"reset",
		"default":"*YES"
	},
	{
		"name":"ccsid",
		"default":"1208"
	},
	{
		"name":"debug",
		"default":"*NO "
	},
	{
		"name":"debug_file",
		"default":" "
	},
	{
		"name":"dump_file",
		"default":" "
	}	
  ]
}

Any parameters that are specified in the configuration file that is used will override those use previously with the MAILTOOL command.

If you are using the G4MSMAIL subprocedures then the order that you set values and load defaults using the #g4msmail_loadDefaults() function will determine which value is used in the end.

Following is an example program:

     H DFTACTGRP(*NO) ACTGRP('G4MS') BNDDIR('G4MS')
      ****************************************************************
      * Imports
      ****************************************************************
      /COPY QCOPYSRC,P.G4MSMAIL
      ****************************************************************
     D CRLF            C                   CONST(X'0D25')
      *
     D rc              S             10i 0
     D errorMsg        S            256
     D displayErr      S             52
      ****************************************************************
      /free

       rc = #g4msmail_init();
       rc = #g4msmail_setValue('configuration_file':'*DFT');
       rc = #g4msmail_loadDefaults();

       if (rc < 0);
         #g4msmail_dumpSettings(); // This will make a json file with settings and values
       else;
         rc = #g4msmail_addRecipient('bvstone@gmail.com':'Brad@Gmail':g4ms_TO);
         rc = #g4msmail_setValue('subject':'Hello there!');
         rc = #g4msmail_setValue('message':'*STMF');
         rc = #g4msmail_setValue('message_stream_file':'/tmp/test.txt');

         rc = #g4msmail_sendMail(g4ms_uniqueID:errorMsg);

         if (rc < 0);
           #g4msmail_dumpSettings(); // This will make a json file with settings and values
           displayErr = errorMsg;
           DSPLY displayErr;
         endif;

       endif;

       EXSR $return;
       //***************************************************************
       //* Return
       //***************************************************************
       begsr $return;

         *INLR = *ON;
         return;

       endsr;
      /end-free

You will notice that the configuration file is *DFT.  This special value will first look for a configuration file named /bvstools/g4ms/config/<userid>/defaults.json where "<userid>" is the user id of the person running the application.

Instead of *DFT you can also specify the fully qualified path to the configuration file you wish to use.

New Functions

Three new functions are also available with G4MS.

#g4msmail_init() - This is used to initialize everything before running the application.  This isn't required to be used, but it is a good idea to use it if you want all the default values set before you continue with your application.

#g4msmail_loadDefaults() - As mentioned previously, this function is used to set values from a configuration file.  The configuration file is set using the #g4msmail_setValue('configuration_file':<config>') command.

#g4msmail_dumpSettings() - This function is used to dump the settings for your application.  Should G4MSMAIL encounter an error sending the email, this function is automatically called so that along with debug files, the settings used will also be available.


Last edited 01/16/2017 at 16:21:17



Latest Posts:

MAILTOOL Updated to Allow G4GSMAIL as Option in Routers File MAILTOOL Updated to Allow G4GSMAIL as Option in Routers File
Posted by 3 days ago
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
BVSTools Now Offers Interface with Infor's ION APIs BVSTools Now Offers Interface with Infor's ION APIs
Posted by May 15, 2020
BVSTools >> BVSTools Announcements
More V7R4 IFS File CCSID Issues and The Fix More V7R4 IFS File CCSID Issues and The Fix
Posted by March 4, 2020
IBM Power Systems >> (QGPL) IBM i
Error Retrieving IP Address by Name Error Retrieving IP Address by Name
Posted by February 25, 2020
BVSTools >> BVSTools Software Discussion
Logging jobs that hit an outq Logging jobs that hit an outq
Posted by February 13, 2020
Programming >> CL Programming
GreenTools for Google Apps (G4G) v12.60 Released with Shared Drive Features and More... GreenTools for Google Apps (G4G) v12.60 Released with Shared Drive Features and More...
Posted by February 4, 2020
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Allowing Requests over Port 80 For SSL Validation (ie, Namecheap, etc) Allowing Requests over Port 80 For SSL Validation (ie, Namecheap, etc)
Posted by January 31, 2020
Programming >> Web Programming
GreenTools for Slack (G4SLK) v3.00 Released GreenTools for Slack (G4SLK) v3.00 Released
Posted by January 17, 2020
BVSTools >> BVSTools Announcements >> GreenTools for Slack (G4SLK) Specific Announcements
Calling a QSH Command from RPG Calling a QSH Command from RPG
Posted by December 26, 2019
Programming >> RPG Programming
SPLTOOL Print Range (PRTRNG) Function Updated to Handle Spooled Files up to 999,999,999 Pages SPLTOOL Print Range (PRTRNG) Function Updated to Handle Spooled Files up to 999,999,999 Pages
Posted by December 14, 2019
BVSTools >> BVSTools Announcements >> Spooled File Tools (SPLTOOL) Specific Announcements
GreenTools for Microsoft Apps (G4MS) Updated to v6.00 - Now Uses Microsoft Graph APIs GreenTools for Microsoft Apps (G4MS) Updated to v6.00 - Now Uses Microsoft Graph APIs
Posted by November 24, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
V7R4 Changes CCSID of Compressed File Using PASE JAR Command - Here's The Fix V7R4 Changes CCSID of Compressed File Using PASE JAR Command - Here's The Fix
Posted by November 21, 2019
IBM Power Systems >> (QGPL) IBM i
Using GETURI to Make OAuth 2.0 Requests - Custom Headers for Access Tokens Using GETURI to Make OAuth 2.0 Requests - Custom Headers for Access Tokens
Posted by November 11, 2019
BVSTools >> BVSTools Software Discussion >> Get URI (GETURI) Specific Discussion
GreenTools for Microsoft Apps (G4MS) v5.00 Released with Updated OneDrive Support and 3rd Party Functionality GreenTools for Microsoft Apps (G4MS) v5.00 Released with Updated OneDrive Support and 3rd Party Functionality
Posted by October 20, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
BVSTools is Now Running V7R4M0 BVSTools is Now Running V7R4M0
Posted by September 28, 2019
BVSTools >> BVSTools Announcements

Reply




Copyright 1983-2020 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).