Dynamic Email from MBT/ESQL

CREATE COMPUTE MODULE Send_Mail
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();

CALL CopyMessageHeaders();

-- Add recipient information to the EmailOutputHeader
SET OutputRoot.EmailOutputHeader.To = 'info@dtm.ie';

-- Add sender information to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.From = 'trevor.oconnell@dtm.ie';


-- Add subject to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.Subject = 'Test.';

-- Add SMTP server information to the LocalEnvironment
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='mail.dtm.ie:25';
SET OutputLocalEnvironment.Destination.Email.SecurityIdentity ='MyIdentity';

-- Create a new message body, which will be sent as the main text of the email.
SET OutputRoot.BLOB.BLOB = CAST('This is the new text for the body of the email.' AS BLOB CCSID 1208);  

RETURN TRUE;
END;

CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;

CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;

Comments

  1. hello Trevor O Connell,
    I used the gmail as my smtp server.And i got the exception shown below.

    Text:CHARACTER:530 5.7.0 Must issue a STARTTLS command first. oy8sm14062097pbc.52

    I don't know where to issue this strattls command.Plesae help me out of this
    regards,
    Venkatasiva,India

    ReplyDelete

Post a Comment

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Configure Database Connection using MyBatis