如何在 Siebel 服务器脚本中发送长电子邮件?

How can I send long emails in Siebel server script?

简而言之:当电子邮件正文超过 40.960 个字符时,如何使用 Siebel 的 Comm Outbound Email buscomp 发送电子邮件?我可以改用 Outbound Communications Manager BS(或另一个),但我也需要创建 activity 记录。


在 Siebel 7.8 中,您可以通过几种不同的方式发送电子邮件:

  1. F9 打开 Send Communications Applet,其中 Send 按钮调用底层 BC Comm Outbound EmailEmailSend 方法:发送电子邮件并创建新的 activity 记录(S_EVT_ACTS_EVT_MAIL 表)。邮件正文没有长度限制。

  2. 从服务器脚本,您可以使用Outbound Communications Manager service method SendMessage。它也没有长度限制,但是它不会在Siebel BCs中创建任何记录,它只是发送消息而不留下任何痕迹。

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);
  1. 或者您可以通过自己创建 BC 记录并调用(未记录?)EmailSend 方法来复制 F9 行为。问题是您 不能设置超过 40.960 个字符的 Display Email Body 值,否则会出现 SBL-DAT-00235 错误。
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");

为什么我在 Display Email Body 中被限制为 40.960 个字符(这个数字是从哪里来的?),而 F9 小程序没有这个限制?我知道那个领域很特别;对于初学者,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 已定义(无值)。此外,它没有映射到任何列:它是一个计算字段,但没有计算表达式;我猜 BC 的 CSSBCOutMail class 管理它。但是,无论我是从脚本还是从小程序使用它,它都应该是一样的。为什么不是,我应该在任何地方更改任何内容以启用它吗?

我的要求是从服务器脚本发送长电子邮件,但我也需要创建 activity 记录。在调用 Outbound Communications ManagerSendMessage 时是否可以设置任何隐藏参数以创建 activity 记录?或者如果我这样做可以避免错误的任何方法 bc.SetFieldValue("Display Email Body", aVeryLongEmailBody);?

我在 Oracle 支持网站上找到 this document (1676136.1),它回答了一个类似的问题:

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.

他们提供的解决方法与我们使用的相同:使用 Comm Outbound Email BC 创建 activity 记录。但是他们没有直接使用 NewRecord 和一堆 SetFieldValues 来完成,而是使用 Inbound E-mail Database Operations 业务服务:

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");

这样做可以避免奇怪的 40960 个字符限制。

如果有人需要它,显然还有一个 UpdateRecord 方法,在 BS 定义中 but it's hidden。参数类似:BusObjBusCompId(您要更新的记录的行 ID),以及每个要更改的字段的 Field: Name Of The Field