How can I send long emails in Siebel server script? - email

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.

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

Forward Emails preserving recipients (INDY and Delphi)

I retrieve eMails from a GMail account with a TIdIMAP4-object and want to forward them with TIdSMTP to an other (GMail-)account while preserving the original list of recipients.
My approach was adding the destination address as BCC to make it invisible in the destination, but how can I prevent the SMTP component from sending it to all the other recipients in the list? They then would get all the forwarded mails twice.
UPDATE 1:
Instead of using BCC I provided the destination address in the send statement
smtp.Send(msg,destination);
but the message is still sent to all the other recipients.
By default, TIdSMTP.Send() will send the email to all of the recipients listed in the Recipients, CcList and BccList properties of TIdMessage.
When you download an email into a TIdMessage via POP3 or IMAP, the Recipients and CcList (but not the BccList) are filled in from the email's existing To and CC headers, respectively.
When you then forward the email, if you do not want it to be sent to the recipients specified in the email, then you can call the overloaded version of TIdSMTP.Send() that takes a recipient list as a parameter. That will send the email ONLY to that list. For example:
var
forwardTo: TIdEmailAddressList;
begin
...
forwardTo := TIdEmailAddressList.Create;
try
// add desired recipients to forwardTo as needed, then...
smtp.Send(msg, forwardTo);
finally
forwardTo.Free;
end;
...
end;

MailKit: How to get the To email address when it is an alias

I am sending an email to alias#company.com which is an alias to a real mailbox address. I then connect to the real mailbox (let's say realmailbox#company.com) using MailKit and retrieve messages. When I inspect the To address, all I see is the realmailbox#company.com. How to I see the original alias address that the email was sent to?
For example:
var fullMessage = imapClient.Inbox.GetMessage(uid);
var recipients = fullMessage.To;
recipients only show the realmailbox#company.com, not the alias#company.com.
It sounds to me like your SMTP server is performing a string substitution on the alias before passing it along to the recipient mailbox making it impossible to get the info you are looking for.

Sending EMails with Indy with multiple CCs. If one is incorrect nobody recieves the mail

I currently setting up a little tool for my company that is used to send info-mails to specific user groups.
But if one or more email addresses are incorrect (missing letter etc.) I get following error and the email isn't sent at all:
EIdSMTPReplyError
Requested action not taken: mailbox unavailable
invalid DNS MX or A/AAAA resource record
I set up the email like this:
adding the first email as main recipient
adding all others to the cclist
Is there a way to set up the email so atleast the other recipients are getting the email?
Some Infos:
Delphi 7
Indy 10
Thanks in advance <3
TIdSMTP has an OnFailedRecipient event:
type
TIdSMTPFailedRecipient = procedure(Sender: TObject; const AAddress, ACode, AText: String;
var VContinue: Boolean) of object;
AAddress is the email address, and ACode and AText contain the error details.
If VContinue is set to True (the default when OnFailedRecipient is assigned), the failed email is skipped and the next recipient is attempted.
The EIdSMTPReplyError exception is raised if either:
OnFailedRecipient is not assigned when a recipient fails.
VContinue is set to False.
all recipients fail, regardless of OnFailedRecipient.

How to send an email with IBM Message Broker?

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>