Why does NotesDocument.send() insert "!\n " into HTML MIME body? - xpages

I'm using NotesDocument.send() to send HTML mails. With server-side javascript, the HTML code (html) is added to the NotesDocument (doc) as follows:
session.setConvertMime(false);
...
var mimeBody:NotesMIMEEntity=doc.createMIMEEntity("Body");
var stream:NotesStream=session.createStream();
stream.writeText(html);
mimeBody.setContentFromText(stream,"text/html;charset=\"UTF-8\"",NotesMIMEEntity.ENC_NONE);
Sending the document works, but if the length of the HTML content exceeds a certain size, the resulting mail contains the string "!\n " at multiple positions. I thought there might be a problem with the MIME conversion and added "MailConvertMimeOnTransfer=0" to the notes.ini. Unfortunately, this didn't help.
Does anyone know how to solve this problem?
PS: I also tried using Mark Leusink's HTMLMail class from OpenNTF (http://openntf.org/XSnippets.nsf/snippet.xsp?id=create-html-mails-in-ssjs-using-mime), but I also faced the problem described above.
UPDATE:
The problem only occurs with mails sent to internet users. Notes users recieve the correct HTML mail.

The problem can be solved by altering the encoding of the MIME entity. I just changed the encoding from NotesMIMEEntity.ENC_NONE to NotesMIMEEntity.ENC_IDENTITY_8BIT, and now the "!\n " strings a no longer inserted into to mail body when executing NotesDocument.send().
All the credit is due to stwissel who provided this solution.

Related

What does the error msg ENVELOPE_HAS_DUPLICATE_RECIPIENTS mean?

Looking at the envelope JSON there is only one recipient email. So this must indicate some other issue. Can someone steer me toward something in the docs that talks about it?
Thanks
I suggest that you use the API Logging feature to see exactly what DocuSign is receiving from your application.
If that doesn't help you solve the problem then edit your question to add the logger's output.
Use a tool such as JSON Pretty print to format your API request.
You'll also need to add 4 spaces per line so StackOverflow recognizes it as software/JSON for proper display.
The answer is it means the request JSON has duplicate RECIPIENTS arrays. It doesn't mean, at least in this case, there is a problem with recipient data.
And as far as a list of error codes there simply isn't one yet.
In this particular instance my code assembling the request incorrectly wrote the recipients array. A better message would be MALFOMED_JSON_REQUEST or such since that's what the problem actually was. Once I stopped looking at the recipients data I realized the problem.

How can I loop SOLines in MailSettings email Body for Acumatica ReportDesigner

Our customers would like us to include fields from the SO Lines in our Sales Order confirmation email, which we are making available to be sent as part of the MailSettings Body for the Sales Order Confirmation report created through ReportDesigner.
Hypothetically, we are able to loop SO Lines like this for an Email Notification by using a foreach loop in the HTML, but I have been unsuccessful with this approach. (The GUI insists on translating my <> symbols into the ascii codes when I try save the directly edited HTML.)
I do not see a way of doing this at all in the MailSettings Body. How can I loop the data here?
EDIT: I found the instructions for linking to the email notification template from within the report so I can use one for both, so if anyone can help solve the mystery of using the within the Email Notification HTML without it automatically replacing the <> characters with ascii that will also solve my problem.
I used html comments to get <foreach> to work correctly inside of a table:
<table>
<!-- <foreach view="Transactions"> -->
<tr><td>Column 1</td><td>Column 2</td></tr>
<!-- </foreach> -->
</table>
I was able to solve this using the Notification Template; my error was in trying to do the loop in the HTML code instead of pasting directly into the Visual page. Functionality is quite limited in terms of being able to add headers for the table outside of the loop, but I got it working by adding another table outside the loop and setting width percentages for both tables. Ugly, but functional.

How do you extract data associated with an image that is an attachment to a Notes RichTextItem?

I've seen things that skirt around this question, but nothing that answers it directly.
I have a RichTextItem in a document that contains an attached image. If I look at the document properties for the field, it says:
Data Type: MIME Part
Data Length: 7615 bytes
...
"Content-Transfer-Encoding: binary
Content-Type: image/jpeg
then a bit of binary data. How can I extract that data in server-side javascript so that I can use it in the value of an image control? In other words, I want the data corresponding to that image to appear in the following so that it renders in the web browser:
<xp:image><xp:this.value><![CDATA[#{javascript:"data:image/jpeg;base64,<DATA HERE>
Can this be done? I've tried all sorts of things but to no avail.
Thanks,
Reid
There a several approaches you can play with.
The "cheat" way: use ....nsf/0/unid/RTItemName?OpenField in a dojo panel as its source. (see here. It would open the whole RichText.
Eventually you need OpenElement instead - can directly address an attachment
Last not least, since your field isn't actually RichText, but MIME, you can use the Notes MIME classes to get to the content and render it base64. The mime classes allow to get the data as stream as well as provide methods to then encode it, so you don't need an extra encoder class
Hope that helps

PHPMailer HTML e-mail gets quoted

I'm sending HTML mails through PHPMailer to my Gmail account (Inbox app), but I cannot build a body which wouldn't get quoted
(you get new e-mail and all there is is "..." which you click and rest of the mail shows, it's for hiding previous conversation if you Reply).
I have tried including tags, but as soon as I add <br> or <p>, it all gets quoted.
Best I could make work was
$message = "<html><body><p>Lalalala</p> trololo </body></html>"
which resulted in Lalalaa "...", if I add paragraph around trololo, all I get is "..."
Anybody came accross this?
After very deterministic experience (one mails sent 2x got quoted differently each time), the thing that helped was wrapping the entire mail in <span> tags.

How can I read a general html form fields send by POST method to my xPage?

I have a common HTML non-xpages form(part of non-xpages application) and I need to submit entered values to xpage and process it. How can I access these html form fields from xpage? In common I access html fields by its xpages componentId, but there is no such in this case.
Also from javascript I need to send JSON data to xpage using http://api.jquery.com/jQuery.post/, how can I access the submitted data? I tried to read some xPages API available here http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/XPagesExtAPI/8.5.2/index.html (specifically here http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/XPagesExtAPI/8.5.2/com/ibm/xsp/context/ExternalContextEx.html ) but it doesnt contain any comments and some mathods have very strange/common siganture like "java.lang.Object getRequest()" ... what is the request here( is it HttpServletRequest ???), where I can find some explanation?
Values posted to XPages can be read using param.get(). I have written a blog post about a HTTP request consumer in XPages that you can use as inspiration.
Although a solution was posted and accepted, (a long time ago) it should be noted that you don't have to use Xpages for this. Posting data to a 'normal' document record or using a basic LS agent and parsing out the posted 'content' would work just as well.

Resources