Author |
Message
|
broker_new |
Posted: Thu May 29, 2008 6:53 pm Post subject: SendMailPlugIn(HTML format) |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
I have done a lot of research in sending an email in HTML format.
My flow contains the following nodes.
MQInput-->>Compute---->>SendMailPlugIn
MQInput takes XML message and in compute node the From,To,Subject fields are set.By default it sends the message in plain text format(ContentType="text/plain).
My requirement is to send it in text/html format.
I have set it different formats with the following statements but iam not able to send it in HTML format.
1)SET OutputLocalEnvironment.Destination.ContentType = 'text/html' ;
2)SET OutputRoot.Properties.ContentType = 'text/html' ;
3)SET OutputRoot.BLOB.BLOB = CAST(InputRoot.XML.Message.Body AS BLOB ccsid 1208); -- NOTE: InputRoot.XML.Message.Body points to your HTML data. Change this accordingly.
SET OutputRoot.XML.Message.Body = 'This is the body of the email';
SET OutputRoot.XML.Message.EncodingBase64.(XMLAttribute)ContentType = 'text/html';
SET OutputRoot.XML.Message.EncodingBase64.(XMLAttribute)Name = 'Sample.html';
When Step3 is implemented i was able to send it in HTML format but the message is sent as an attachment but it has to be included in the Body of Email.
Could anyone help me configuring this to send the Email in HTML format. _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
dcjs |
Posted: Fri May 30, 2008 7:46 am Post subject: |
|
|
Acolyte
Joined: 10 Nov 2006 Posts: 53 Location: IBM Bangalore
|
Broker has lot of limitations.
I dont think sendmailplugin can be configured to send Emails in HTML format.
Use Core Java to send the email.
You know all the functionalities of Broker can be implemented in Java _________________ TRY TRY UNTIL U SUCCEED |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri May 30, 2008 7:47 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Set the Body to be the HTML text.
Or use EmailOutput node in V6.1.
 _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
broker_new |
Posted: Fri May 30, 2008 7:48 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
That means SendMailPlugin can't be configured to send HTML based emails to include the payload in the Body. _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
broker_new |
Posted: Fri May 30, 2008 11:15 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
Jeff,
I have coded like this as you said but iam not able to get the correct output.
SET OutputRoot.XML.Message.From = 'abc@abc.com';
SET OutputRoot.XML.Message.To = 'abc@abc.com';
SET OutputRoot.XML.Message.Subject= 'Test EMail is to test the HTML Capability';
SET OutputRoot.XML.Message.Body.HTML.Body='<body bgcolor=#d4d4d4>
<h1>hello</h1></body>';
But iam getting the output as am i doing any mistake here <body bgcolor=#d4d4d4><h1>hello</h1>
</body>' _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
dcjs |
Posted: Fri May 30, 2008 11:31 am Post subject: |
|
|
Acolyte
Joined: 10 Nov 2006 Posts: 53 Location: IBM Bangalore
|
its not correct.
Broker 6 doesn't support HTML email formatting. _________________ TRY TRY UNTIL U SUCCEED |
|
Back to top |
|
 |
broker_new |
Posted: Wed Jun 04, 2008 12:39 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
And at last i found a way to send an email in HTML format using JCN.
I created ah HTML message using a compute node and passed it to JCN.
package com.ibm.www;
import java.util.Date;
import java.util.Enumeration;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.*;
public class HTMLEmail_MsgFlow_JavaCompute extends MbJavaComputeNode {
public static int sendMail(String message) throws Exception
{
String host = "smtp-out.yahoo.com";//SMTP host address
String subj = "Test HTML Message created By Broker using a Custom Node";
String to = "abcd@abc.com";
String from = "abcd@abc.com";
StringTokenizer st = new StringTokenizer(to, ";");
Vector v = new Vector();
int cnt = 0;
while (st.hasMoreTokens())
{
v.addElement(st.nextToken());
cnt++;
}
InternetAddress[] address = new InternetAddress[cnt];
Enumeration enum1 = v.elements();
for (int i=0; i<cnt; i++)
address[i] = new InternetAddress(((String) enum1.nextElement()).trim());
// String myname = "Broker_New is the best!!";
Properties props = new Properties();
props.put("mail.smtp.host", host);
Session session = Session.getDefaultInstance(props, null);
// create a message
MimeMessage mimemessage = new MimeMessage(session);
MimeBodyPart mimebodypart = new MimeBodyPart();
mimebodypart.setContent(message, "text/html");
MimeMultipart mimemultipart = new MimeMultipart();
mimemultipart.setSubType("alternative");
mimemultipart.addBodyPart(mimebodypart);
mimemessage.setFrom(new InternetAddress(from));
mimemessage.setRecipients(javax.mail.Message.RecipientType.TO, address);
mimemessage.setSubject(subj);
mimemessage.setSentDate(new Date());
mimemessage.setContent(mimemultipart);
Transport.send(mimemessage);
return 0;
}
public void evaluate(MbMessageAssembly contact admin) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");
MbMessage inMessage = contact admin.getMessage();
MbElement root = inMessage.getRootElement();
String str = (String) root.evaluateXPath("string(./MQRFH2/usr/str)");;
try
{
sendMail(str);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
} _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
broker_new |
Posted: Wed Jun 04, 2008 1:23 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
We need to understand one thing there are lot of limitations in Broker and we go for custom nodes to provide that feature using Java.
In case of sendmailplugin as it provided as a support pac it doesn't have all the features of sending an email(like the problem i faced).
But there are some limitations where we can't do anything like configuring Broker to listen on multiple HTTP and HTTPS ports.
Calling two different databases(oracle,db2..) using a single compute node.
...................
I read the documentation for 6.1 each execution group can be configured to a separate HTTP and HTTPS port and lot of new features.
Sometimes even after deleting the execution groups those will be showing up in debug mode............. _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
|