Mail as plain text in Netsuite - netsuite

Whenever I send a mail from netsuite, It goes in Rich text format (HTML format).
Instead, I want to send it in Plain text format.
I tried many ways but not working. even when I send it with just as a string it goes in HTML format.
E.g.:
var email_subj = "Mail Subject";
var mail_content = "This goes in Body";
nlapiSendEmail(1234,'abc#gmail.com',email_subj,mail_content ,null,null,rec_MailID);
The above mail too goes to the recipient in Rich Text Format.
Is there a way so that it goes in Plain text format.
To know whether the mail is in rich text or plain text you can inspect the body element in browser of the recipient and you will see that there are HTML contents in the mail body.
Or if you are using Outlook: you can right click the body content and there will be option called "View Source" if you click it you will see the HTML code.
Note: in outlook if the mail is in Plain text format then "View Source" option is disabled you cannot click on it, that is what i want.

SuiteScript 1.0 appears to wrap all email bodies in HTML tags.
SuiteScript 2.0 N/email module(ie: email.send() ) will format as plain text unless you include markup in the body. Mock code:
require(['N/email'],
function(email) {
function sendEmail() {
email.send({
author: 1234,
recipients: 'abc#gmail.com',
subject: 'Mail Subject',
body: 'This goes in Body',
});
}
sendEmail();
});

Related

my link is sent as a plain text in email using mailgun

I am trying to send a link in email using mailgun but the anchor tag in html sent as plain text
mg.messages().send({
from: 'mohamed.salah678mo#gmail.com',
to: email,
subject: `${req.currentUser.courseId} results are published by ${req.currentUser.userName}`,
html: `<html>
<body>
<a href='localhost:5000/api/course-results'>results</a>
</body>
</html>
`
}, (error,body) =>{console.log(body.message)})
this returns the word result as a plain text not a clickable link

Base64 encoded image sent using sendgrid not displayed in mails

I am trying to send a logo image in the HTML using sendGrid mailing service. I went through a lot of articles and tried a lot but still could not figure out on how to display inline image using content_id.
I went through following links but still could not make it work:
[Link1][1]: https://sendgrid.com/blog/embedding-images-emails-facts/
[Link2][2]: https://github.com/sendgrid/sendgrid-nodejs/issues/841
Few of the answers suggest to add image as a base64 string in HTML but that does not work with few web mailing clients.
Here is my code:
`
try
{
const msg = {
to: `${customerData.raw[0].invoicemail}`, // List of receivers email address
from : 'xxxx#xxx.com',
subject: `${subject}`, // Subject line
html: emailData, // HTML body content
attachments:
[
{filename:`${filename}`,content:invoice,type:"application/pdf"},
{filename:'logo.jpg',content:logoImageData,content_id:'logo',type:"image/jpg",disposition:"inline"}
],
}
sgMail.send(msg)
//return this.mailerService.sendEmail(msg)
}
catch
{
return false
}`
And here is the HTML block:
<img src = "content_id:logo" alt = "Logo Image" width=140 height=20>
Also, the image is being received as an attachment but is not displayed.
Sorry for the very late reply, I've also had trouble getting my image to display using SendGrid.
#Abhijeet, have you tried replacing src = "content_id:logo" with src="cid:logo"?
For other beginners, like myself, using SendGrid I will include the other steps that #Abhijeet already has done.
Upload and convert your image file to base64 (we'll call this logoImageData).
We want to replace the beginning of the base64 encoded image string using String.prototype.replace().
export const cleanLogoImageData = logoImageData.replace('data:image/jpeg;base64,' , '')
Now, in the attachments for mail data for SendGrid, you need to add these to your object: filename, content, contentType, content_id, and disposition.
const msg = {
attachments: [
{
filename: "logo.jpg",
content: cleanLogoImageData,
contentType: "image/jpeg",
content_id: "logo",
disposition: "inline",
},
],
}
content_id and disposition: "inline" are what got my logo to show.
Finally, in the html file holding your <img />, you must set the src as cid:logo or whatever your content_id is. And moreover, it's recommended to add align="top" and display: block in your img tag for better and consistent cross-platform email display of the image.
<img align="top"
style="display: block"
src="cid:logo"
alt="company logo"
/>

Attachment links in Body field in Notes Web UI

I need to modify classical Notes Web UI application. In the UI, it shows mail data. If the data has attachments, they are shown as links in the body field.
I'd like to detect when a user clicks the links, and enable "next" button so that the user can move to the next screen. Is it possbile?
Yes, and this has nothing to do with Domino specifically: put a div around your next button, that initially has the style display: none or give itself an ID and put the display: none directly in the properties box of the button on the html tab, fields ID and style.
Then write a little JavaScript that runs in the onLoad event, selects all a tags with attachments in it (they all have $FILE in the href) and add a function to the click- event to set the style of the button to display: block or something else.
You can prevent the default event (open the attachment) by using preventDefault():
var list = document.getElementsByTagName("a");
for (el of list) {
if (el.href.includes("$FILE")) {
el.addEventListener("click", function(event){
var yourNextDiv = document.getElementById("IDOfDivWithNextButton")
yourNextDiv.style.display = "block"
event.preventDefault()
});
}
}

Nodemailer - Unable to send clickable link

I am using nodemailer for sending emails from my nodejs app. I am successfully able to send an email. But, if I want to send a link, the href or anchor tag is not working. That is the link does not go as part of the mail. The rest of the text is sent. Any ideas?
Here is the relevant code :
var messagebody = "Hello ".concat(req.body.name).concat(", One of your team mates have submitted an application form for intern next summer. Please approve or reject the same on the internship portal. Best Regards.");
var mailOptions = {
from: from, // sender address
to: to, // list of receiver
// cc: cc,
subject: subject, // Subject line
text: messagebody, // plaintext body
html: ' Hello '.concat(req.body.name).concat(' , <br /></br > One of your team mates have submitted an application for intern(s) for next summer. Please approve or reject the proposal on the internship portal. <br /> Here is the link of the internship portal : <br /><br /> Best Regards.') // html body
};
Your code is Correct but you havn't wrote anything in between <a></a> tags.
Just put some text between them and it will work.
Click here
You can also render a jade (or pug) file and get it as a string
const render = jade.compileFile('./views/my_email.jade');
const html = render(content);
const mailOptions = {
from: from, // sender address
to: to, // list of receivers
subject: subject, // Subject line
html: html
};
where content is the array with the data you want to pass to the jade file

How to add pass thru html in javascript in a notes rich text item

I am building a XPAGES app. and want to send a url link to the user to specific documents.
In my code I add a rich text style and the link.
The link is not converted to the word "link" with the actual html link on it..
Tried also square brackets around the complete link url.
Any ideas?
var nrtStyle:NotesRichTextStyle = session.createRichTextStyle();
nrtStyle.setPassThruHTML(0);
msgbody.appendStyle(nrtStyle);
msgbody.appendText('link')
Here is the SSJS code to send an email to current user with a link to current XPage:
session.setConvertMIME(false);
var doc:NotesDocument = database.createDocument();
doc.replaceItemValue("Form", "Memo");
var body:NotesMIMEEntity = doc.createMIMEEntity();
var header:NotesMIMEHeader = body.createHeader("Content-Type");
header.setHeaderVal("multipart/mixed");
header = body.createHeader("Subject");
header.setHeaderVal("Link to XPage you visited");
header = body.createHeader("To");
header.setHeaderVal(context.getUser().getDistinguishedName());
var stream:NotesStream = session.createStream();
stream.writeText('Link to XPage');
body.setContentFromText(stream,"text/html;charset=UTF-8", NotesMIMEEntity.ENC_NONE);
stream.close();
doc.send(false);
session.setConvertMIME(true);
It creates a new document with an included MIME entity with header and content.
The email sent contains the HTML link in body:
Look here for more information.
Why try and do this inside a Rich Text? Use an XPages Link control directly on your page.

Resources