Forums >> Programming >> Proof of Concept (POC)
Using a Stream File as the Message Body of an Email Using MAILTOOL or G4MS ILE Subprocedures
by: bvstone

Jump to: 






bvstone

Using a Stream File as the Message Body of an Email Using MAILTOOL or G4MS ILE Subprocedures

Posted:
Using a Stream File as the Message Body of an Email Using MAILTOOL or G4MS ILE Subprocedures

I was recently asked what would be the proper way to send an email using an existing HTML document (which resides in the IFS) as the body of an email.

Using the MAILTOOL ILE subprocedures it would look like the following:

// init and set other values

fileName = '/tmp/docs/letter.html';  //This should be the fully qualified path to the file
rc = #mailtool_setValue('message':'*ATT');          
rc = #mailtool_setValue('body_content_type':'text/html');   
rc = #mailtool_addAttachment(fileName);    

// send the email

If you are using the G4MSMAIL addon to G4MS, your code would look like this:

This should be all you need.

// init and set other values

fileName = '/tmp/docs/letter.html'; //This should be the fully qualified path to the file
rc = #g4msmail_setValue('message':'*STMF');           
rc = #g4msmail_setValue('message_stream_file':fileName);
rc = #g4msmail_setValue('message_content_type':'html');

// send the email

As always, feel free to contact us with any questions.


Last edited 06/19/2017 at 11:39:09




Reply




Copyright 1983-2017 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).