Update: 08/28/2019 - Google has verified the G4GSMAIL Addon
We recently updated GreenTools for G Suite (G4G) to include functions in the F.G4GMAIL service program that will allow you to send emails via Google's RESTful API interface.
We have also added functionality to MAILTOOL that will allow you to send using this method. Simply register the service for your G Suite or GMail account and use the SENDWITH(*G4GSMAIL) option.
You can also use this functionality in your own programs using the g4gmail_sendMail() function. Here is the prototype:
*//////////////////////////////////////////////////////////////* * g4gmail_sendMail - Send an Email using Gmail API * * * * Output: * * out_id - The ID of the email message (if successful). * * out_threadID - The Thread ID of the email message. * * out_errMsg - The error message (if error exists). * * * * Returns: * * -1 for error, 0 for success * * * * Settable Variables ([r]=required) * * id - Google ID [r] * * sendmail_mime_file - The fully qualified path to the MIME * * file of the email you want to send. [r] * * message_id - The message/thread ID to apply to this email. * * ccsid - The CCSID to use (1208) * * debug - Turn on Debug (*NO, *YES) * * * *//////////////////////////////////////////////////////////////* D g4gmail_sendMail... D PR 10i 0 D out_id 256 Options(*NOPASS) D out_threadID 256 Options(*NOPASS) D out_errMsg 256 Options(*NOPASS)
All you need to provide is a properly formatted MIME file in the IFS and the API will do the rest. Or, if you don't have any applications that create email MIME files the MAILTOOL application can do that heavy lifting for you.
If you are using a 3rd party or open source email application this function will make it easy to simply plug this into your application and start using GMail functionality with your applications.
Using this application does require licensing of GETURI, the G4G base product and the G4GSMAIL addon. If you wish to use it with MAILTOOL you will need a license for that as well. But you will not require a MAILTOOL Plus license unless you require the functionality offered by the Plus Addon.
Google does enforce a 35MB maximum size for the entire message (after it's base 64 encoded). That size limit is checked by G4G before attempting to call the API.
You can see a video of the process on YouTube by clicking here.
As always, feel free to contact us with any questions.