Skip to content

Instantly share code, notes, and snippets.

/*
* Send a newsletter or any emails to multiple users easily, no need to use bcc
* If you are a workspace user with license > Business Standard you already have the multi-send
* https://support.google.com/google-workspace-individual/answer/11243118
*/
function sendMyNewsletter() {
let emails = 'COMA_SEPARATED_LIST_OF_EMAILS_NO_SPACE'
let subject = 'SUBJECT OF THE EMAILS IN YOUR DRAFT';
let draft = GmailApp.getDraftMessages().find(message => { return message.getSubject() == subject });
// I put that here if that can help someone,
// if you have the error "dns.setDefaultResultOrder is not a function" in node.js (nodejs)
// or dns.setDefaultResultOrder("ipv4first");
// or TypeError: dns.setDefaultResultOrder is not a function
// in the Google Cloud IDE or not, you have to update your node js so enter : nvm install stable
// Then you need to make it default enter : nvm alias default stable
// If that can help
function countLabels() {
var labels = GmailApp.getUserLabels();
var count = 0;
for(var key in labels){
count++;
}
console.log('You have '+ count +' labels in Gmail.')
}
@St3ph-fr
St3ph-fr / pushSubmissionToHangoutsChat.js
Last active November 12, 2022 02:51
Push Google Forms Submission to Hangouts Chat with Apps Script and Webhook
/**
* This script will allow you to push form submission in a Hangouts Chat space by using Webhook
*
* How to setup ?
* 1 - Create a Hangouts Chat space
* 2 - Add people
* 3 - Create Webhook : https://developers.google.com/hangouts/chat/how-tos/webhooks
* 4 - Create a form and go to Apps Script editor
* 5 - Copy paste code below
* 6 - Replace Webhook url int the code for URL_WEBHOOK
@St3ph-fr
St3ph-fr / gist:3247014
Created August 3, 2012 12:11
Google Apps Script - List de the public file of the DocsList in Google Apps Script
// #GoogleAppsScript #Gscript #GoogleSpreadsheet
function getPublicFiles(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var docs = DocsList.getFiles(); //Retrieve all the docs.
var listfile = "";
var viewer = new Array;
var owner = "";
var me = Session.getUser().getEmail(); //Get the email of the script owner. Need it to check if you are the owner of the file.
for(var i in docs){
@St3ph-fr
St3ph-fr / gist:3246991
Created August 3, 2012 12:07
Google Apps Script - Delete all the data in the scriptdb database of a google script
// #GoogleAppsScript #Gscript #GoogleSpreadsheet
//from google help page : https://developers.google.com/apps-script/scriptdb
function deleteAll() {
var db = ScriptDb.getMyDb();
while (true) {
var result = db.query({});
if (result.getSize() == 0) {
break;
}
@St3ph-fr
St3ph-fr / gist:3246983
Created August 3, 2012 12:05
Google Apps Script - Add all the data in a google spreadsheet to the scriptdb database
// #GoogleAppsScript #Gscript #GoogleSpreadsheet
//Personalised from google help page : https://developers.google.com/apps-script/scriptdb
function setup(){
ScriptProperties.setProperty('sheet', SpreadsheetApp.getActiveSpreadsheet().getId());
}
function addAll() {
var spreadsheet = SpreadsheetApp.openById(ScriptProperties.getProperty('sheet') );//Run setup in first to initialise script var 'sheet'.
var columns = spreadsheet.getLastColumn();