I opened up a spreadsheet and inserted a Drawing to use it as an Action Button, then I assigned the following script to it:
function sendEmail() {
var emailAddress = 'myemail#gmail.com';
var message = 'test-message';
var subject = 'test-subject';
MailApp.sendEmail({
to: emailAddress,
subject: subject,
htmlBody: message
});
}
Everytime I click the button from a PC, it works fine, I receive the test email instantly. But when I try to test it using any sort of mobile device it won't let me click the button.
Why hasn't google fixed this?
How can I effectively make my script send an email from google sheets using a mobile device? I've already tried with onEdit() and data validation instead of buttons but this doesn't work with the MailApp.sendEmail function, so it doesn't resolve my problem.
Please help
This is a known issue(Star it to show support). Apps Script works from official mobile apps, but buttons with scripts assigned to them do not.
onEdit simple trigger does not work because you need email sending permissions. For this case, an onEdit Installable Trigger can be used.
Related
I'm using appium-flutter-driver & webdriverIO to automate the flutter mobile app.
I have a use case in my application where clicking on
Mail us button opens Gmail app with subject, body
Call us button opens Dailer app with phone number
I want assert/verify that gmail/phone app is opened. either one of following is fine
verifying that gmail/phone app package name
verifying the subject, content in gmail compose screen is also fine
I see here https://github.com/appium-userland/appium-flutter-driver that
await driver.switchContext('NATIVE_APP');
await (await driver.$('~fab')).click();
what is ~fab means here?
How to find elements using ID, text, class in this case and perform click, enterText, etc operations?
I'm not sure what ~fab means. But the available finders are mentioned here, with links to the documentation. The available commands are mentioned here, with links to the documentation.
An example of a finder by semantics label with a click:
element = FlutterElement(self.driver, FlutterFinder().by_semantics_label('Back'))
element.click()
An example of entering text:
driver.execute_script('flutter: enterText')
Got these examples from here.
I have a google sheet shared with other people (I'm the owner) and in it there is a button linked to a corresponding bundle script that send me an email when the user logged press that button (so if I click the button I send an email to me).
All the other people have the "edit" privileges but when they click the button an error occurs saying that it's impossible to send the mail (when I click all works perfectly).
The accounts associated to the other people has the same email domain of mine (not gmail, but related to the same company).
It seems like that the script has different privileges because I have no problem, while the other people do.
As normal, at the first time they click to the button they (but also me) had to accept the google authorization to "send email as you" (as the avatar of the current account logged).
This is the code of the button:
'''
var sheet = SpreadsheetApp.getActiveSheet();
var sel = sheet.getSelection();
var sel_range = sel.getActiveRange();
var message = sel_range.getValues();
// get task IDs
var prev_values = sel.getNextDataRange(SpreadsheetApp.Direction.PREVIOUS).getValues();
var cod_tickets = [];
for (var k in prev_values){
cod_tickets.push(prev_values[k][0]);
}
var emailAddress = SpreadsheetApp.getActive().getSheetByName('Manager').getRange('I2').getValue();
var subject = 'ticket ' + cod_tickets;
MailApp.sendEmail(emailAddress, subject, message);
'''
I say that they send an email to me, because the "emailAddress" variables will be filled with the value of the cell that contains my email address.
Any ideas?
Have a look at the documentation for restrictions for simple triggers:
They cannot access services that require authorization. For example, a
simple trigger cannot send an email because the Gmail service
requires authorization, but a simple trigger can translate a phrase
with the Language service, which is anonymous.
Solution:
Use an installable trigger instead.
Go to Edit->Current Project's trigger
Click on +Add trigger
Select event type On edit.
Your function should no be named onEdit, because otherwise both the simple and installable trigger would fire at once which can lead to problems.
The problem:
The installable trigger will fire for every user, but it will fire on your behalf, so the email will always be you.
If this is a problem, you will need to use a service account that will impersonate the session user, which will make things more complicated.
I am really new to google script (never used before)and I think I am trying to run before i can walk
I need to be able to send and email to a list of people but each person will need a different attachment, I don't have a clue.
Any ideas on where i should look?
Here's a good place to start. It's a tutorial created by google.
https://developers.google.com/apps-script/articles/sending_emails
Here's Google Apps Script Class MailApp documentation.
https://developers.google.com/apps-script/reference/mail/mail-app
Another tutorial...
https://ctrlq.org/code/20118-mandrill-send-email-google
Hope that helps you get started.
In terms of structure on your spreadsheet, you will need a column list of email address and beside each email address so unique identification of the attachment that is to be sent. You would then loop through each row of that sheet and send an email for each address.
Refer the below code to send multiple mails with different email id, subject, body and attachment. Hope this helps!
function sendEmail(){
var openSpreadSheet = SpreadsheetApp.openById("<<YOUR SPREADSHEET ID>>").getSheetByName("Sheet1");
var data = openSpreadSheet.getRange(2,1,openSpreadSheet.getLastRow()-1,4).getValues();
for(var i=0;i<data.length;i++){
MailApp.sendEmail({
to:data[i][0],
subject: data[i][1],
htmlBody: data[i][2],
attachments:[DriveApp.getFileById(data[i][3]).getBlob()]
})
}
}
This is how the spreadsheet is configured.
I have deployed a custom workflow, and have email notifications correctly setup for each task. The email links currently look like the following:
https://myCompany.com/share/page/task-details?taskId=activiti$58788
This link takes the user to the details view of the task, and requires them to hit the "Edit" button at the bottom to actually perform the task. Ideally, I would like to change the link to the following:
https://myCompany.com/share/page/task-edit?taskId=activiti$58788
As task-edit allows them to immediately edit the form and perform the task. How might I go about making this change (for just this workflow)?
To change the email template(s) for all notifications: wf-email.html.ftl located in Data dictionary/Email templates/Workflow notification
Change the following html snippet:
${shareUrl}/page/task-details?taskId=${args.workflowId}
Into
${shareUrl}/page/task-edit?taskId=${args.workflowId}
If you're using your own notification mechanism, then create a new email template based on this one and use the path in your Mail task or JavaScript mail action.
---UPDATE---
You can use this JavaScript in you're workflow to send an email, still it's easier to use the AlfrescoMailtask.
// create mail action
var mail = actions.create("mail");
mail.parameters.to = "test#alfresco.com";
mail.parameters.subject = "You've got mail";
mail.parameters.from = "server#alfresco.com";
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow notification/My_custom_Template.ftl");
mail.parameters.text = "some text, in case template is not found";
// execute action against a document
mail.execute(document);
(Using Liferay 6.1.0-CE-GA1.) I have written my own user registration portlet. When I UserLocalServiceUtil.addUser(...), the sendEmail parameter is true and, indeed, it sends the Account Verification Notification.
I've modified that notification by adding this line to it:
Please verify your email address for [$PORTAL_URL$] by clicking this link: [$EMAIL_VERIFICATION_URL$].
Unfortunately the e-mail it sends contains this line, literally:
Please verify your email address for xxx by clicking this link: [$EMAIL_VERIFICATION_URL$].
Is there any way to make this work? I want to send one e-mail with the verification code. My program flow requires it.
Thank you.
You should use this after you added the account in the action
ServiceContext serv = ServiceContextFactory.getInstance(request);
UserLocalServiceUtil.sendEmailAddressVerification(user1, user1.getEmailAddress(), serv);