Show email in web application from gmail api - node.js

Developing an application which will show mails from Gmail.
Fetched messages from Gmail api with the help of following links
https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list
https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get
Got mail body in base64 encoding. Decoded the mail body and got HTML.
can you please help to show this HTML in div and not get affected by previous css.
Tried css property from https://css-tricks.com/almanac/properties/a/all/
all: unset;
But it didn't work.

When you decode the mail body, it returns a string. You need to convert this string to HTML. There are various npm packages available for the same. Try node-html-parser once, it should solve your problems.

Related

How to use Twilio to send customized PDF’s from Google Drive/Sheets

I am having problems trying to send customized PDFs from Google Drive to users on WhatsApp using Twilio’s API.
I am using node.js and the documents are created in Google Sheets and stored in Google Drive.
client.messages
.create({
mediaUrl:['https://drive.google.com/uc?id=INSERT_FILE_ID&export=download'],
from: 'whatsapp:+14155238886',
body: `It's taco time!`,
to: 'whatsapp:+15017122661'
})
.then(message => console.log(message.sid));
I thought it would be possible to send the PDF by passing the PDF’s Drive link through MediaURL as that is what is recommended on Twilio’s site for sending media (Images, .mp3’s and PDF’s) but when I try that it doesn’t work.
NB: it works when I try image URL’s etc.
I have tried sending the webContentLink of the PDF that also doesn’t work.
example: how the pdf should look when sent
I do not want to send the user a normal link for them to leave WhatsApp.
Any help with this or any other method to achieve this would be greatly appreciated.
Twilio will check the content-type of the file which you have been passing in the mediaUrl parameter. Twilio will reject if the content-type headers of your media attachment do not match the file extension (for example, content-type is image/jpg but the file extension is .png). It specified in the following links specifies:
Twilio Troubleshooting
Twilio supported-mime-types

How to fetch a specific inline image using OWA REST API?

I'm developing OWA add-in using OWA REST API
When fetching the message item, I can see in the body if there's an inline image added which is looks like
<p style="margin-top:0; margin-bottom:0">
<img class="EmojiInsert" src="cid:773570bf-3178-41a4-97ac-4e3eddef859f" style="">
<br>
</p>
in the src I can see the contentId of the attachment but the resource reference did not says if this property is searchable or filterable, and I cant $select it in the odata query params, therefore I cant get that attachment!
the alternative way was to fetch the list of the attachments by doing:
https://outlook.office.com/api/v2.0/me/messages/{id}/attachments
but that will:
1- fetch all attachments with their contentBytes which is too expensive!
2- if the admin increase the minimum upload to be more than 35MB I might got error with that request i single attachment >35MB, see this question that no one answer it yet
3- I alway got some attachments that I did not upload, sometime from outlook it self (VERY WIERD) other time if I upload an attachment(s) and remove it I still get it when fetching the attachments, so some time I have for example 3 attachments but I got 12!!
Is there a way to know the inline image attachment id? and then get that attachment?

I want to send email attachment using nodemailer in node js.i am using elasticemail gate way

I need to send a URL attachment in nodemailer.i try to many ways but mail was not deliverd.I was seen elasticemail gateway they showed a error like this "suppressed" how will i solve this issue
attachments:[{ // use URL as an attachment
filename:'GSTR3B_33ADQFS8223E1ZY_012019_1551501263.pdf',
path:'my url'}]
if you are getting "suppressed" from Elastic Email check in the Contacts section on your dashboard to be sure that the contact is in an "Active" state. The contact might be suppressed by the system.

DocuSign - Random UNABLE_TO_CONVERT_DOCUMENT error

I am using Docusign create envelop API using the endpoint https://au.docusign.net/restapi/v2/accounts/{AccountID}/envelopes. The API call works on most instance but occasionally I am receiving an error stating that the System was unable to convert this document to a PDF. I am submitting a docx type document which is failing randomly(say once in a day). On re submission the same document submission works without any issue.
In order to understand the problem I tried enabling logging on DocuSign login. Since the log can only keep upto 50 entries at any given time I am clearing the log to ensure I am ready to capture the failure when it happens.
Actual Error Message received:
{
"errorCode": "UNABLE_TO_CONVERT_DOCUMENT",
"message": "System was unable to convert this document to a PDF. Unable to convert Document(Document Name.docx) to a PDF. Error: UserId:{GUID} IPAddress:XX.XX.XXX.XXX Source:ApiRESTv2:Failed to convert FileType: docx"
}
Now I am trying to download the log file via DocuSign UI and I am receiving constant timeout issue while trying to do so. Does anyone know about any programmatic log file extract from DocuSign? Anyone done this previously?
Any pointers on the error resolution or help downloading the error log is much appreciated. Please help
The DocuSign platform by default accepts PDF documents so when sending through the API you simply need to include the document bytes for PDFs. However for any other file format you need to set the fileExtension property on the document object to the file type you are sending.
For example if using one of the open source DocuSign SDKs use the setFileExtension() setter method to set the extension:
document.setFileExtension("docx");
Or if you are calling the REST API directly (ie not using an SDK) then set the fileExtension property to "docx":
{
...
"fileExtension": "docx",
....
}
If you still receive the error after this then you I would start testing with a different document and confirm the document you are using not corrupt in any way and if properly formatted.

HTTP Error 405.0 - Method Not Allowed while Form Post

I posted a request to payu server via form submit using angularjs now once payment is completed payu will return a response with hash.But when it hits my success page i get "HTTP Error 405.0 - Method Not Allowed".I found many solutions online but none of that solved my issue.What i understood is that static html do not allow post by default.But my staticFile in IIS is like below
Request Path : *
Module : StaticFileModule
Name : staticFile
Request Restriction >Verb > All Verbs & Access > Script & Invoke > Files and folders
My question now in how to allow POST method for html page.I am using angular and if i change my success url to other than mine it works fine.I think there is some changes to be made to the web config but i tried my best but failed.Any help would be much appreciated.Also lets assume that the page successfully redirects to my success page how to capture the response that payu sends me online.
Thanks in advance if more input is needed from my side kindly ask in reply.
It's not that HTML does not allow POST by default, it's that HTML does not handle POST, period. (Not even if the HTML file contains JavaScript.) POST sends data to a script that runs on your server, and the script has to be smart enough to know what to do with the data. HTML isn't that smart. The only thing your server can do with HTML is to send the HTML back to whatever is requesting it. You need a server-side script that knows how to parse payu's response, do something appropriate with the hash, and then generate some HTML to display in the user's browser.

Resources