I'm using npm pacakge to open mail client with data:
https://www.npmjs.com/package/react-native-mail-compose
Also, I'm using their example:
import MailCompose from 'react-native-mail-compose';
// later in your code...
async sendMail() {
try {
await MailCompose.send({
toRecipients: ['to1#example.com', 'to2#example.com'],
ccRecipients: ['cc1#example.com'],
bccRecipients: ['bcc1#example.com', 'bcc2#example.com'],
subject: 'This is subject',
text: 'This is body',
html: '<p>This is <b>html</b> body</p>', // Or, use this if you want html body. Note that some Android mail clients / devices don't support this properly.
attachments: [{
filename: 'mytext', // [Optional] If not provided, UUID will be generated.
ext: '.txt',
mimeType: 'text/plain',
text: 'Hello my friend', // Use this if the data is in UTF8 text.
data: '...BASE64_ENCODED_STRING...', // Or, use this if the data is not in plain text.
}],
});
} catch (e) {
// e.code may be 'cannotSendMail' || 'cancelled' || 'saved' || 'failed'
}
}
and call this function on button press. All data is OK, except body, for example here in Subject there is "This is subject", in CC of mail clients, there is "cc1#example.com", but body is always empty, I can't ever see "This is body" in mail client.
I've fixed it with another package react-native-send-intent.
It works like a charm! :)
I see, give this package a try.
https://github.com/anarchicknight/react-native-communications
Its very simple to use
Related
I want to respond to an inline query but there is no response from my bot. However, Telegram returns {"ok":true,"result":true} as the HTTP response. Here's my Google Apps Script code:
var execute = "https://api.telegram.org/bot" + token + "/";
function answerInlineQuery(id,text){
var output = {
method: "post",
payload: {
method: "answerInlineQuery",
inline_query_id: id,
result: [{
type: "article",
id: id,
title: "This is a title",
description: text,
input_message_content: {
message_text: text,
},
}]
}
};
UrlFetchApp.fetch(execute,output);
}
How do I solve this? Is there something wrong with my code? Or is there something to do with the bot settings (BotFather)?
In case you need a demonstration of the problem, try the bot yourself by using an inline query (type #ClearTheBot [something] in any chat).
https://t.me/ClearTheBot
Please kindly change output.payload.results[0].id to 1 and/or JSON.stringify(output.payload.result)
I have the following code:
const input = document.querySelector('input')
btn.addEventListener('click',() => {
Email.send({
Host: 'smtp.gmail.com',
Username:'',
Password:'',
To:input.value,
Subject:"",
From: '',
Body:''
}).then(msg=>console.log(msg))
And in the body I want to send a photo, on the next row text and then a hyperlink(or even the button) Is it possible or smtpjs does not provide that functuonality? Couldn't find anything
Or maybe there is another source(not smtpjs), where I could write a template of the letter and then send it
To send the files, you can define the attachment.
Email.send({
SecureToken : "<your security token>",
To : '<whom you want to send>',
From : "<Your email id registered on SMTPJS>",
Subject: "<Subject>",
Body: "<Body Content>",
Attachments:
[{
name: "File_Name_with_Extension",
path: "Full Path of the file"
}]
})
.then(function (message) {
//
}
Next, if you want to send the hyperlink, I think you can use the html content on body instead of text.
...
Body: "Click <a href='[full_path of link]'>here</a> <button>Button</button>",
...
But the onClick event or other javascript actions will not work for button.
Thank you
I have the following lines, This is what I tried, and it works fine but I want to load a template for drawing the content inside, how can I attach a file for being displayed as a content of the email? Here comes what I have:
attachment:[{data: req.__({ phrase: 'Please click this link to reset your password: https://website.com/reset/%s', locale: locale}, user.uuid), alternative:true}]
How can I load a path to read the content from something like an HTML file?
I can use a template adding this lines:
var forgotTemplate = fs.readFileSync('../public/mailplates/forgot');
and then:
attachment: [{data: forgotTemplate, alternative:true}]
Anyway, I need to fit the "hash" for change the password, how can i add a script line inside or at least a string?
var email = require("./path/to/emailjs/email");
var server = email.server.connect({
user: "username",
password:"password",
host: "smtp.your-email.com",
ssl: true
});
var message = {
text: "... ",
from: "...",
to: "...",
subject: "testing emailjs",
attachment:
[
{data:"<html>i <i>hope</i> this helps</html>", alternative:true},
{path:"path/to/file.zip", type:"application/zip", name:"renamed.zip"}
]
};
// send the message and get a callback with an error or details of the message that was sent
server.send(message, function(err, message) { console.log(err || message); });
Finally, a solution is with Jade, i add:
var jade = require('jade');
and then:
var forgotTemplate = jade.renderFile('../public/mailplates/forgot.jade', {userRecover: userInfoRecover});
The Jade template must display something like this:
doctype html
html
head
title = forgot password
body
h1 this works
a(href='#{ userRecover }') link
When I try to create an envelope from a template I get a response of:
{ errorCode: 'UNSPECIFIED_ERROR',
message: 'Non-static method requires a target.' }
Here's what I'm doing so far:
First I login, which returns
{ loginAccounts:
[ { name: '*****',
accountId: '*****',
baseUrl: 'https://demo.docusign.net/restapi/v2/accounts/******',
isDefault: 'true',
userName: '***** ********',
userId: '*******-*****-*****-*****-*********',
email: '********#*******.com',
siteDescription: '' } ] }
So then I take the baseUrl out of that response and I attempt to create the envelope. I'm using the hapi framework and async.waterfall of the async library, so for anyone unfamiliar with either of these my use of the async library uses the next callback to call the next function which in this case would be to get the url for the iframe, and with our usage of the hapi framework AppServer.Wreck is roughy equivalent to request:
function prepareEnvelope(baseUrl, next) {
var createEntitlementTemplateId = "99C44F50-2C97-4074-896B-2454969CAEF7";
var getEnvelopeUrl = baseUrl + "/envelopes";
var options = {
headers: {
"X-DocuSign-Authentication": JSON.stringify(authHeader),
"Content-Type": "application/json",
"Accept": "application/json",
"Content-Disposition": "form-data"
},
body : JSON.stringify({
status: "sent",
emailSubject: "Test email subject",
emailBlurb: "My email blurb",
templateId: createEntitlementTemplateId,
templateRoles: [
{
email: "anemailaddress#gmail.com",
name: "Recipient Name",
roleName: "Signer1",
clientUserId: "1099", // TODO: replace with the user's id
tabs : {
textTabs : [
{
tabLabel : "acct_nmbr",
value : "123456"
},
{
tabLabel : "hm_phn_nmbr",
value : "8005882300"
},
{
tabLabel : "nm",
value : "Mr Foo Bar"
}
]
}
}
]
})
};
console.log("--------> options: ", options); // REMOVE THIS ====
AppServer.Wreck.post(getEnvelopeUrl, options, function(err, res, body) {
console.log("Request Envelope Result: \r\n", JSON.parse(body));
next(null, body, baseUrl);
});
}
And what I get back is:
{ errorCode: 'UNSPECIFIED_ERROR',
message: 'Non-static method requires a target.' }
From a little googling it look like 'Non-static method requires a target.' is a C# error and doesn't really give me much indication of what part of my configuration object is wrong.
I've tried a simpler version of this call stripping out all of the tabs and clientUserId and I get the same response.
I created my template on the Docusign website and I haven't ruled out that something is set up incorrectly there. I created a template, confirmed that Docusign noticed the named form fields, and created a 'placeholder' templateRole.
Here's the templateRole placeholder:
Here's one of the named fields that I want to populate and corresponding data label:
As a side note, I was able to get the basic vanilla example working without named fields nor using a template using the docusign node package just fine but I didn't see any way to use tabs with named form fields with the library and decided that I'd rather have more fine-grained control over what I'm doing anyway and so I opted for just hitting the APIs.
Surprisingly when I search SO for the errorCode and message I'm getting I could only find one post without a resolution :/
Of course any help will be greatly appreciated. Please don't hesitate to let me know if you need any additional information.
Once I received feedback from Docusign that my api call had an empty body it didn't take but a couple minutes for me to realize that the issue was my options object containing a body property rather than a payload property, as is done in the hapi framework.
I am trying to use Cordova plugin called Email Composer to let users send emails. Cordova Email Plugin
I am generating some html content and want to prefill body of the email with the content.
The code I have tried:
function emailHtml(text) //variable to fill the body
{
cordova.plugins.email.isAvailable(
function (isAvailable) {
cordova.plugins.email.open({
to: 'your#email',
cc: 'second#mail',
bcc: [],
subject: 'Greetings',
body: text //the HTML content
});
}
);
}
But it does not work yet.
What is the proper way to use variables for the plugins fields?
Thanks.
You can actually do it by plain Javascript , No need to add additional plugin and increase the build size
let Link="mailto:someone#example.com?subject=Hello%20again";
window.open(Link, "_system");
You can add all the parameter you need in the link.
You need to use parameter isHtml: true
myHTML="<html> ......... </html>";
cordova.plugins.email.isAvailable(
function (isAvailable) {
cordova.plugins.email.open({
to: 'your#email',
cc: 'second#mail',
bcc: [],
subject: 'Greetings',
body: myHTML, //the HTML content
isHtml: true // indicats if the body is HTML or plain text
});
}
);