I am looking for a simple answer. I have created a script to send an email through Google Sheet Script Editor:
function mailtest() { MailApp.sendEmail("name.surname#etteachers.com",
"Availability Change",
"Hi Please note that...."); }
The body of the email however keeps all the text in one row starting at the top of the email body. How do I get the part "Please note that" two rows below "Hi" in the email?
Add two new lines to your message like this:
function mailtest() {
MailApp.sendEmail(""name.surname#etteachers.com", "Availability Change", "Hi\n\nPlease note that....");
}
Related
I created a form to collect some data. By default the responder to the form gets a PDF summary after submitting the Email. Does anybody know if it is possible to send this summary to a second Email adress I mean a copy of the summary to the form Hoster?
Thanks a lot in advance.
Cheers
Basically repeating what I said in the comments there is no way to add another email address by the UI but you could try to use Apps Script.
You can use a onFormSubmit(), this is a installable trigger that executes every time a form is submitted.
You could try to look at this SO answer, where there is a definition of a trigger and sending a email:
/**
* This function is the one that will be executed every time the trigger is activated
*/
function respondToFormSubmit() {
MailApp.sendEmail ("email#domain.com", "Form Submited: Foo feedback " + Date.now(), "Form Submited: Foo feedback");
}
The setup of the trigger:
var form = FormApp.getActiveForm();
var trigger = ScriptApp.newTrigger('respondToFormSubmit')
.forForm(form)
.onFormSubmit()
.create();
This is a similar question to this link, but slightly different:
Skipping blank emails in Google Apps Script Mail Merge
I have a form/sheet set up that, when the users fills out the form, it generates a receipt email (does not contain the form contents as some receipts do) that is then sent to the recipient. However when the user leaves this field blank I get a form trigger error, which is understandable why the script didn't finish. I am trying to figure out how to keep the script from attempting to send an email when the recipient/email field is blank. Unfortunately, making the email field required on the form is not an option since, oddly, not everyone would have an email address (if this were an option I would certainly just require an email address to be entered).
I have tried the following code snippet based on the link provided above.
// Send Email to recipient(s) declared above in #var sendEmail
if (e.values[11] != null) {
var sendEmail = e.values[11]; //email field column
var subject = "subject message";
var body = "body message";
MailApp.sendEmail(sendEmail, subject, body, {
name: "Community Home Health Care",
body: body,
noReply: true,
})
I have also tried instead of
(e.values[11] != null)
using
(e.values[11] != "")
The remaining code I have omitted (goes above what I have shown) simply takes the form field responses and generates a document converted to a PDF which works as expected. The email section also works, just trying to eliminate the failed script emails I get occasionally.
Thanks
First is an assumption that 12 items are passed (0 through 11) and the email is the last item to be passed. If that is the case, then test that the item is defined with:
if(typeof e.values[11] !== 'undefined')
If you are using the Mail Merge Tutorial linked to in the post you linked to, and using the getRowsData() function to get your form responses, you should be able to use the Header of the column containing the email address such as e.values.emailAddress and get:
if(typeof e.values.emailAddress !== 'undefined')
This may vary based on how your data is defined.
How can I make slack parse #someone mentions as links to the user instead of plaintext. I've been reading slack documentation on message formatting but still haven't figured it out. Here's an example of what I'm getting now:
{
"text": "*username:* #alexis",
"response_type": "ephemeral"
}
To make a proper "clickable" mention, you need to pass the unique user ID and not the plaintext name.
The format of the user ID is: U024BE7LHand a mention would look like this: <#U024BE7LH>
Ther user ID of the user that executed the slash command will be in the payload that slack sends to your endpoint. You can also look up user IDs by calling the users.list method, which will give you access to the user IDs of all the users in the team.
More information here
Pass the username inside <> quotes like this <#someone>
Sample
{
"text": "*username:* <#alexis>",
"response_type": "ephemeral"
}
Also if instead of user you want to notify channel then use !channel, !group , !here , or !everyone instead of #username
For eg.
{
"text": "*username:* <!channel>",
"response_type": "ephemeral"
}
slack_web_client.chat_postMessage(
channel="channel_name",
text="Hi! <#User_id>"
)
Place User ID in <> quotes and make sure that your app/bot has Scopes for commands.
Further details - https://api.slack.com/interactivity/slash-commands
I'm using Mandrill in Nodejs to send emails to customers, and want to embed an image in my html content attached to the emails. I found some solutions from https://mandrill.zendesk.com/hc/en-us/articles/205582457-Tips-for-using-images-in-Mandrill-emails and decided to use the 4th one, which includes the image inline in the html. The code is as below:
var message = {
html: htmlContent,
subject: "Subject",
...
images = [{
"type": logo.logoType, // which is "image/jpeg"
"name": "logo",
"content": content // the content is valid when using in <img src="data:image/jpeg;base64,content"> directly
}]
};
mandrillClient.messages.send({
message: message
}, function() {
callback(null);
}, function(err) {
callback(err);
})
And the corresponding html code in htmlContent is
<img src="cid:logo">
However, when I checked with the sent email in Mandrill Outbound Activity, "View Content" doesn't show the image correctly. And I looked at the html source, found the image code was still as
<img src="cid:logo">
The plain text didn't get replaced by image data.
How can I get it work properly? Any ideas?
Thanks in advance.
Finally I found it just didn't work when checking the sent email in Mandrill Outbound Activity, but it works fine in your actual email inbox. So it means you will never see the embedded image when do testing, you must send it with production api key and see the results in a real email inbox.
Just FYI. Hope no one will waste any time on this like I did. :)
In Worklight, I have setup Push message for iOS and it works fine. Now for testing purpose, when i am sending push via URL call then the message title comes correctly while the body (payload) part truncates all spaces and shows all words together.
For example:
http://mydomain/myApp/invoke?adapter=aaPushAdapter&procedure=sendPush¶meters=["aahad","General Title 2", "This is General message body 2"]
then , title comes as "General Title 2" and the body part comes as "ThisisGeneralmessagebody2"
My Adapter is declared as:
function sendPush(userId, msgTitle, MsgContents){
var userSubscription = WL.Server.getUserNotificationSubscription('aaPushAdapter.PushEventSource', userId);
if (userSubscription==null){
return { result: "No subscription found for user :: " + userId };
}
WL.Server.notifyAllDevices(userSubscription, {
badge: 1,
sound: "sound.mp3",
activateButtonLabel: "Read",
alert: msgTitle,
payload: {
msg : MsgContents
}
});
return { result: "Notification sent to user :: " + userId };
}
(1) Now how I can preserve this formatting ?
(2) If i have to send URL then how i format and send my message?
Please suggest. Thanks
If %20 does not work, then change all spaces to something like '|', and then unencode this in your app. Or hex encode the whole string so it's one continuous alphanumeric string.
I am not entirely sure how you are using the URL as a means to send the push notification. Do you mean that you actually go to the browser and type this text in the address bar...? You're not supposed to do that (for other than quick tests). There are backend systems that should do that for you.
Anyway, instead of the space between words, use "%20" (w/out the quotation marks) and see if the text is then displayed with spaces in the dialog.