I am using MailKit to reply to an email received from a Gmail account. I set the value of the In-Reply-To and References header as described in the MailKit documentation:
if (!string.IsNullOrEmpty(replyMessage.MessageId)) {
message.InReplyTo = replyMessage.MessageId;
foreach (var id in replyMessage.References) {
message.References.Add(id);
}
message.References.Add(replyMessage.MessageId);
}
Given this, I expect the reply mail to show up in Gmail as a reply to the original message. However, this does not happen. The mail is shown like any other random new mail.
Am I missing something?
You also need to set to message.Subject to “Re: “ + replyMessage.Subject
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.
Description of the issue
I am sending emails in JavaScript with
message2 = message.replace("<br>", "\n")
GmailApp.sendEmail(address, subject, message2, {
cc: cc,
name: sendername,
htmlBody: message
});
…where message is a long string containing HTML tags.
On my Gmail account the email that is received contains a … in the middle to hide/extend the end of the message. The … correspond to newlines (<br>) but it seems to chose a newline randomly that will be used to split the message randomly.
I cannot get rid of all <br> of course. I always saw these … to separate the main part of the email from the signature. But in my case it just appears anywhere as for example right after the first line:
Question
How does GMail choses the “breakpoints” for shortening the message?
How can I avoid that GMail uses “breakpoints?”
Should I use something else than <br> to make newlines?
Working on a customised email template in CQ5, I have created in following text file under etc/notification. The workflow is triggered when a form is filled in by the user.
From: Order Brochure <order.brochures#gmail.com>
To: ${payload.email}
CC:
Subject: Order Brochures Confirmation ${payload.BrochureID}
Dear ${payload.Name},
Thank you for your Brochure Order, your reference is ${payload.orderBrochureID}.
Your email address is {$payload.email}.
Everything in this template works fine, except for the "To: ${payload.email}". Even the "Your email address is {$payload.email}" part displays the user inputted email fine. It also works if I input a static email address in "To:".
What am I doing wrong here? Below is the error in logs
Process execution resulted in an error:
javax.mail.internet.AddressException: Illegal address in string ``''
com.day.cq.workflow.WorkflowException: javax.mail.internet.AddressException: Illegal
address in string ``''
Remove the "CC:" it's attempting to parse the email address for this header and it's a null.
When you're dealing with these types of problems when the error is occurring within a CQ library. I recommend using a custom logger to assist with the troubleshooting.
Details of logging can be found at Logging - docs.day.com
Here's an example OSGi log configuration for your issue.
This error might be cumming because you are using a string as an Internet Address.
you need to typecast ${payload.email} to Internet Address.
I have a Google Apps spreadsheet that is filled by user-submitted forms. I'm trying to write a script that verifies that the Email field filled by the users is valid. I'm using MailApp to send a confirmation email and catching errors, like this:
try {
MailApp.sendEmail(address, subject, message, {'htmlBody':htmlMessage, 'noReply':true});
Logger.log("Sending email to " + address);
} catch(e) {
return "Failed: Invalid address";
}
This works fine for immediate errors (null or malformed addresses), but not for non-existing email addresses. To catch those, until now I used the following code to wait 5 seconds and then check the inbox for Mail Delivery Notification emails:
Utilities.sleep(5000);
var threads = GmailApp.search("is:unread subject:\"delivery status notification\" " + address);
if (threads.length > 0) {
return "Failed: Delivery failed. " + threads[0].getPermalink();
}
This worked fine last year when I used it last, but trying now, I don't get the mail delivery notifications messages anymore when sending mail via script - apparently Google changed something, and now only manually sent messages receive the notification.
So given that my previous method has stopped working, does anyone have any idea of an alternative, automated method to verify the emails work?