How to send an email with IBM Message Broker? - email

As a part of overall project, I need to create one Message-Broker application which accepts data in XML format and produce email.
I created one message flow like below
"MQ Input - Compute - emailoutput"
Please help me what should I write in xml file to generate the above flow.
The esql file contain the below code:
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
-- Add recipient information to the EmailOutputHeader
SET OutputRoot.EmailOutputHeader.To = '<recipient email address>';
SET OutputRoot.EmailOutputHeader.Cc = '<recipient email address>';
SET OutputRoot.EmailOutputHeader.Bcc = '<recipient email address>';
-- Add sender information to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.From = '<sender email address>';
SET OutputRoot.EmailOutputHeader."Reply-To" = '<reply email address>';
-- Add subject to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.Subject = 'Replaced by ESQL compute node.';
-- Add SMTP server information to the LocalEnvironment
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';
-- 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;

I have absolutely no idea what xml file you're talking about.
Lay out msg flow in the message broker toolkit, by adding and connecting the three nodes you specified. Then add your code to the Compute Node.

You can pass values Using XPATH, by using InputRoot.XMLNC , using Environment or LocalEnvironment.
If we take your requirements ,
that Seems The Message come from your MQInput node you are using XMLNSC Parser.
-- Add recipient information to the EmailOutputHeader
SET OutputRoot.EmailOutputHeader.To = InputRoot.XMLNSC.EmailData.To;
-- Add sender information to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.From = InputRoot.XMLNSC.EmailData.From;
-- Add subject to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.Subject = InputRoot.XMLNSC.EmailData.Subject;
-- Add SMTP server information to the LocalEnvironment
-- You can Add Smtp Server From Configuration in Your Broker Administration side as Configurable Service
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';
-- Create a new message body, which will be sent as the main text of the email.
SET OutputRoot.BLOB.BLOB = CAST(InputRoot.EmailData.Body AS BLOB CCSID 1208);
For Testing , In Test Client Type this XML File
<EmailData>
<To>recieverEmail#example.com</To>
<From>fooSenderEmail#example.com</From>
<Subject>Testing Email App</Subject>
<Body><![CDATA[<h1>Testing Email Data</h1><br/><hr /><br/><h6>Testing Email</h6></hr />]]></Body>
</EmailData>

Related

AppleScript code for copying new email subject

I'm setting up a rule in my Mail app to execute the AppleScript below when an email from a specific sender arrives. My goal is to copy the incoming email's subject line, however, this script is copying the subject of the currently selected email in the main inbox and not the arriving email's.
Is there a better way to achieve my goal?
tell application "Mail"
set _msgs to selected messages of message viewer 0
if (_msgs is not equal to missing value) then
set _msg to first item of _msgs
set the clipboard to (subject of _msg) as string
end if
end tell
You need to use the built-in handlers that Mail exposes to access the message associated with a rule activation; selected messages of message viewer 0 just accesses the active Mail window (as you describe). Instead, use Mail's on perform mail action handler to correctly access the message. See this question (and this answer) for more information.
Here is your code, re-written to correctly copy the subject line of incoming emails that satisfy the provided rule criteria. It's working for me on macOS Catalina 10.15.5:
using terms from application "Mail"
on perform mail action with messages _msgs for rule _rule
if (_msgs is not equal to missing value) then
set _msg to first item of _msgs
set the clipboard to (subject of _msg) as string
end if
end perform mail action with messages
end using terms from

Multiple To and Cc headers in MIME message sent through LotusScript

I'm building a LotusScript agent looping through a set of documents then - based on a given condition - create mail messages with formatted html text. The recipients will be mostly Non-Notes users (Outlook etc) that's why I want to make sure that subject and message body are formatted correctly. At least one copy is sent to a Domino mail-in database, though.
The code basically creates a MimeEntity, sets "To", "CC" and "Subject" headers then puts a pre-configured message into the mail body and sends it off.
In regards to the body I experimented both with a simple MimeEntity formatted as "text/html" as well as with a multipart message (Content-Type = "multipart/alternative") with 2 child entities (1: "text/plain" without any formatting, 2: "text/html" i.e. html-formatted); in my final code I plan to go for the latter method.
What is really weird is that the recipients (using Outlook as well as other mail clients like Thunderbird) see 3 "To:" and 3 "Cc:" items instead of just one. Looking at the doc in the receiving Domino mail-in database there is only one instance of each item (i.e. SendTo and CopyTo).
Here's the message's source code (taken from Thunderbird) showing those 3 instances of each item:
Return-Path: <sendername#myorg.de>
Received: (removed info here)
Subject: =?UTF-8?B?RWluIGdlbcO8dGxpY2hlcyBzaW1wbGVzIFRlc3RtYWlsIGF1cyBTT1A=?=
MIME-Version: 1.0
Auto-Submitted: auto-generated
To: user1#orgext1.de, user2#orgext2.de
CC: my-mail-in-db#myorg.de
To: user1#orgext1.de, user2#orgext2.de
CC: my-mail-in-db#myorg.de
To: user1#orgext1.de, user2#orgext2.de
CC: my-mail-in-db#myorg.de
Message-ID: <OFBCA50979.C1582837-ONC125856E.00548385-C125856E.0054838A#MYORG.DE>
From: Lothar Mueller <sendername#myorg.de>
This the basic code creating these mails (the simple non-multipart version):
Set docMemo = db.Createdocument()
Call docMemo.Replaceitemvalue("Form", "Memo")
Set nMimeBody = docMemo.Createmimeentity()
'SendTo
Set nMimeHead = nMimeBody.Createheader("To")
Call nMimeHead.Setheaderval("user1#otherorg.de,user2#3rdorg.de")
'CopyTo
Set nMimeHead = nMimeBody.Createheader("CC")
Call nMimeHead.Setheaderval("my-mail-in-db")
'Subject
Set nMimeHead = nMimeBody.Createheader("Subject")
Call nMimeHead.Addvaltext("Subject with ä-ö-ü-ß", "UTF-8")
'html version only for simple non-multipart MIME
Call nStream.Writetext({<p style="font-weight:bold;">Some simple formatted HTML content</p>})
Call nMimeBody.Setcontentfromtext(nStream, {text/html; charset="UTF-8"}, ENC_NONE)
Call nStream.Close()
'finally send
Call docMemo.Send(False)
Now, I can work around this behavior by simply setting the recipients as plain old Notes items, like:
Call docMemo.SendTo = recipientArray
Call docMemo.CopyTo = copyArray
instead of setting those values as MIME headers. In this case there are no more multiple instances of "To" and "CC" items at the recipients' mail clients.
I know that I did this already some years ago in a different project, and back then I didn't have those problems.
Anyone having an idea what could be the cause for this? Could it be due to the Domino version in use (now it's 10.0.1 FP4, back then it was some 9.0.1 version)?
Guess I found the cause for this, at least partially:
As I mentioned in an update to my post this behavior only can be observed when the agent is running in the client as opposed to running on the server:
examining the resulting mail through Ytria's scanEZ I find that there's a difference in regards to the fields that are created:
the run-on-server version just creates the expected fields "To:" and "Cc:" which turn up as "SendTo" and "CopyTo" in the resulting Notes document
If the code is running in the client some more fields are created in the Notes document: in addition to the standard fields there are also "INetSendTo", INetCopyTo, "AltSendTo" and "AltCopyTo". I assume that those extra fields are then rendered by the router to become addition "To:" and "Cc:" header items.
Thanks again to #DaveDelay for bringing up that idea regarding the router and mail.box

Mail Session settings at Websphere Server

The mails are sent with default From address as wasadm#servername which I want to change. I tried using the property mailFrom at application.inf file, changed the values at websphere console - Resources >> Mail >> Mail Sessions >> Return e-mail address but nothing worked out.
Could you please let me know if you have some solution to replace the default from mail address to a custom value.
Normally, the email-sending application code sets a "from" address in the message itself.
That said, I think it might work to set a Mail Session Custom property of mail.from. According to https://javaee.github.io/javamail/docs/api/overview-summary.html:
mail.from The return email address of the current user, used
by the InternetAddress method getLocalAddress.
I know from experience that the envelope sender address can be set with Custom property mail.smtp.from. See https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html
mail.smtp.from Email address to use for SMTP MAIL command. This sets the envelope
return address. Defaults to msg.getFrom() or
InternetAddress.getLocalAddress(). NOTE: mail.smtp.user was previously
used for this.

How can I send long emails in Siebel server script?

In short: how can I send an email using Siebel's Comm Outbound Email buscomp, when the email body is longer than 40.960 characters? I can use the Outbound Communications Manager BS instead (or another one), but I need the activity record to be created too.
In Siebel 7.8 you can send emails in a few different ways:
Pressing F9 opens the Send Communications Applet, where the Send button invokes the underlying BC Comm Outbound Email → EmailSend method: the email is sent and a new activity record is created (S_EVT_ACT and S_EVT_MAIL tables). There is no length limit for the email body.
From server script, you can use the Outbound Communications Manager service method SendMessage. It doesn't have length limitations either, but it doesn't create any record in Siebel BCs, it just sends the message without leaving any trace.
var psOut:PropertySet = TheApplication().NewPropertySet();
var psIn:PropertySet = TheApplication().NewPropertySet();
psIn.SetProperty("ProcessMode", "Remote");
psIn.SetProperty("Charset", "iso-8859-1");
psIn.SetProperty("CommProfile", from);
psIn.SetProperty("MsgToList", to);
psIn.SetProperty("MsgSubject", subject);
psIn.SetProperty("MsgHTMLBody", body);
var bs:Service = TheApplication().GetService("Outbound Communications Manager");
bs.InvokeMethod("SendMessage", psIn, psOut);
Or you can replicate the F9 behaviour by creating the BC record yourself and invoking the (undocumented?) EmailSend method. The problem is that you can't set a Display Email Body value longer than 40.960 characters, otherwise you get a SBL-DAT-00235 error.
var bo:BusObject = TheApplication().GetBusObject("Service Request");
var bc:BusComp = bo.GetBusComp("Comm Outbound Email");
bc.NewRecord(NewAfter);
bc.SetFieldValue("Email Format", "HTML/Plain Text");
bc.SetFieldValue("Email Charset", "iso-8859-1");
bc.SetFieldValue("Email Sender Address", from);
bc.SetFieldValue("Email Sender Name", from);
bc.SetFieldValue("Email To Line", to);
bc.SetFieldValue("Description", subject);
bc.SetFieldValue("Display Email Body", body); // will fail if body.length > 40960
bc.WriteRecord();
bc.InvokeMethod("EmailSend");
Why am I restricted to 40.960 characters (and where did that number come from?) in the Display Email Body, while the F9 applet doesn't have that limitation? I know that field is special; for starters, Siebel 7.8 doesn't support database columns above 16.383 characters, yet this field max length is 1.024.000 (not 40.960...). For that, the field user property Text Length Override is defined (without value). Also, it isn't mapped to any column: it's a calculated field, but without calculated expression; I guess the BC's CSSBCOutMail class manages it. But still, it should be the same whether I'm using it from scripting or from an applet. Why isn't it, should I change anything anywhere to enable it?
My requeriment is to send long emails from a server script, but I need the activity record to be created too. Is there any hidden parameter that I can set when calling Outbound Communications Manager → SendMessage, in order to create the activity record? Or any way to avoid the error if I do bc.SetFieldValue("Display Email Body", aVeryLongEmailBody);?
I found this document (1676136.1) in the Oracle support web, which answers a similar question:
Customer is using Outbound Communications Manager business service method SendMessage to send emails out from a workflow and want to keep an activity record or have a view where they can see the email that were sent out using this method.
The workaround they offer is the same we were using: to create the activity record using the Comm Outbound Email BC. But instead of doing it directly with a NewRecord and a bunch of SetFieldValues, they use the Inbound E-mail Database Operations business service:
var psOut:PropertySet = TheApplication().NewPropertySet();
var psIn:PropertySet = TheApplication().NewPropertySet();
psIn.SetProperty("BusObj", "Mail Agent Activity");
psIn.SetProperty("BusComp", "Comm Outbound Email");
psIn.SetProperty("Field: Description", subject);
psIn.SetProperty("Field: Display Email Body", body);
psIn.SetProperty("Field: Email Sender Address", fromAddress);
psIn.SetProperty("Field: Email Sender Name", fromProfile);
psIn.SetProperty("Field: Email To Line", toAddress);
var bs:Service = TheApplication().GetService("Inbound E-mail Database Operations");
bs.InvokeMethod("InsertRecord", psIn, psOut);
var error = psOut.GetProperty("ErrorMessage"); // "" if everything went ok
var actId = psOut.GetProperty("ID");
Doing so avoids the weird 40960 characters limitation.
In case anybody needs it, apparently there is also a UpdateRecord method, but it's hidden in the BS definition. The parameters are similar: BusObj and BusComp, Id (the row id of the record you want to update), and a Field: Name Of The Field for each field you want to change.

DocuSign attaching a document to an envelope

I was wondering if it was possible to attach a document or documents to an envelope when sending envelopes via SOAP API? I have used the api to create an Attachment object and added the bytes but when I attach to the envelope the status envelope attachments comes back as null and when I look at the docusign email there is no attachment( I'm assuming is due to the fact that attachment returns as null in the status, but when I debug it the attachment is clearly there. Can a sender attach documents to an envelope?
Attachment attachment = new Attachment(){
Data = "bytes",
Label = "name",
Type = "Document"
};
newTemplate.Envelope.EnvelopeAttachment = new Attachment[] { attachment };
Finally I attach the attachment to the envelope and send.
Thank you
The EnvelopeAttachment property of the Envelope object in the SOAP API merely exists as a way for an integrated application to "pass along" another file with an Envelope during the Create Envelope process, such that this file will be associated with the Envelope from that point forward and the integrated application can access it in the future via API if necessary. Files supplied in this manner (i.e., using the EnvelopeAttachment property) will never be visible within the DocuSign UI, or to the recipients of the Envelope in the Envelope itself -- the only way to access them is via the API.
If you merely need to add another file to the Envelope that all recipients will see in the Envelope but that no recipients are required to sign, etc., then you should add that file to the Envelope in the same way that you add all other files to the Envelope (i.e., using Documents property of the Envelope object) and just don't specify any Tabs for that document.