Thursday, 29 October 2020

How to Search Emails in Gmail by Specific Time

Gmail supports a plethora of search operators to help you instantly find that elusive email message buried in your mailbox. You have size search - like larger_than:5mb - to find the big messages in your account. File search - like has:attachment filename:doc - will locate email messages that contain specific file attachments. This graphic illustrates all the known Gmail search operators that work both on Gmail website and mobile.

Gmail Search Tricks

Search by Date in Gmail

Date search in Gmail helps you locate emails sent or received during a specific period. Here are some examples:

  • newer_than:7d from:me - Emails sent in the last 7 days
  • after:2020/10/15 before:2020/10/20 from:uber - Emails from Uber received between October 15 and October 20.
  • newer_than:60d older_than:30d - All emails received in the previous 30-day range.

The date in the Gmail search query is specified in the YYYY/MM/DD format.

Search Emails by Specific Time in Gmail

Gmail supports an undocumented time-based search option that lets you find emails sent or received during a specific hour, minute or event second. For instance, you can limit your Gmail search to emails that were received between October 10 8:15 PM and October 10, 2020 8:45 PM.

Gmail Search Date and Time

To get started, convert the date and time to Epoch time and then use the timestamp with the standard after or before search operator of Gmail.

For instance, the Epoch time for October 10 8:30 PM is 1602774000 and that of October 10 8:45 PM is 1602774900. Use the search query after:1602774000 before:1602774900 to:me in Gmail and you’ll get a list of all emails that were received during that 15-minute period.

Epoch time is the number of seconds that have elapsed since January 1, 1970 (UTC). Use the Epoch converter to represent a human readable date and time in Epoch and use that timestamp with the before or after search operator of Gmail to find that elusive email.

Date and Time Search with Google Script

Here’s a little snippet that will automate your Gmail search by time using the Gmail API. It will fetch all email messages that were received between 12:15 PM and 1:30 PM.

const emailReceived = () => {
  const secondsSinceEpoch = (date) => Math.floor(date.getTime() / 1000);
  const after = new Date();
  const before = new Date();
  after.setHours(12, 15, 0, 0);
  before.setHours(13, 30, 0, 0);
  const query = `after:${secondsSinceEpoch(after)} before:${secondsSinceEpoch(
    before
  )}`;
  const messages = Gmail.Users.Messages.list('me', {
    q: query,
  });
  Logger.log(messages);
};

Also see: Mail Merge for Gmail



from Digital Inspiration https://ift.tt/2jqslgV

How to Change the Reply-to Address in Mail Merge

When you send an email campaign through Gmail, you’ve an option to specify a different reply-to email address for your emails. When the email recipient hits the “Reply” or “Reply All” button, the To field in their email reply will be automatically populated with the email address that you’ve specified as the Reply-to email at the time of sending.

You can even specify more than one email addresses in the reply-to field, separated by commas, and they will all show up in the To field of the reply field. For instance, you could send emails from your own email address but the replies would be received in your email inbox as well as the support team.

To get started, open your Google sheet, go to the add-ons menu and choose Mail merge with attachments.

Next click on the Configure menu to open the Mail Merge sidebar.

Change Reply-to Email address

Here go the Reply-to address file and type an email address. If you wish to receive replies on multiple email addresses, type them all here separated by commas.

Now when you send the email campaign, open one of the emails in the sent items folder, expand the message header and you should see the specified email addresses listed in the reply-to field.

Different Reply-to address

Why is Google Ignoring the Reply-to Address

If you send a test email to yourself, you’ll get the email in your inbox. If you hit the reply button in that message, you may notice that that reply-to field contains your own email address and not the custom email address(es) that you’ve specified in your mail merge.

That’s the default behavior in Gmail if the “from” address on an email message is the same as the “to” address or is one of your own email aliases. To test your reply-to functionality, you should send emails to an email address that is not connected to your current Gmail account or set the “From” address as a non-Gmail address.



from Digital Inspiration https://ift.tt/3jDAkWR

Download Gmail Messages as EML Files in Google Drive

This Google Script will help you download your email messages from Gmail to your Google Drive in the EML format.

What is the EML Format

The .eml file format is popular for transferring emails from one email program to another since it complies with the RFC 822 standard and thus can be natively opened inside Apple Mail and Microsoft Outlook. You can even open EML files inside Google Chrome by dragging the file from your desktop onto a new browser table.

EML files contains the email content (email body, header and encoded images and attachments) as plain text in MIME format.

Download Gmail message as EML Files

Inside Gmail, open any email thread, go to the 3-dot menu and choose “Download Message” from the menu. It will turn your current email message into an eml file and save it your desktop.

However, if you wish to automate the process and download multiple emails as eml files in your Google Drive, Apps Script can help.

const downloadEmails = () => {
  const sender = 'sender@domain.com';
  const threads = GmailApp.search(`from:${sender}`).slice(0, 10);
  threads.forEach((thread) => {
    const subject = thread.getFirstMessageSubject();
    const [message] = thread.getMessages();
    const rawContent = message.getRawContent();
    const blob = Utilities.newBlob(rawContent, null, `${subject}.eml`);
    const file = DriveApp.createFile(blob);
    Logger.log(subject, file.getUrl());
  });
};

The script searches for emails from the specified sender, gets the first email message and downloads it your Google Drive.

Forward Gmail as EML Attachment

If you are to forward an email message as an attachment, the .eml format may be recommended since it preserves all the formatting and attachments of the original email thread in a single file that can be attached to the email.

const forwardEmail = () => {
  const messageId = '123';
  const message = GmailApp.getMessageById(messageId);
  const rawContent = message.getRawContent();
  const blob = Utilities.newBlob(rawContent, null, `email.eml`);
  GmailApp.sendEmail('to@gmail.com', 'This email contains an eml file', '', {
    attachments: [blob],
  });
};

Also see: Download Gmail as PDF Files



from Digital Inspiration https://ift.tt/35HNj4R

Monday, 26 October 2020

Google Drive Monitor - Get Email Alerts When Files are Deleted in your Drive

When you delete a file in Google Drive, it moves to the trash folder and stays there indefinitely until you manually empty the bin. That is how it has always been but, sometime this month, Google made one important change to how the trash bin works.

Under the new policy, files that have been in Google Drive’s trash bin for more than 30-days are automatically deleted. This automatic cleanup does help reclaim space but if you happen to accidentally delete some important files or folders from your Google Drive, there’s no way to restore them from the trash after the 30-day window.

Monitor Google Drive Files

If you are like me who is terrified at the prospect of forever losing important files that were deleted by mistake, Google Drive Watch can help.

Google Drive Watch is an open-source Google Script that automatically monitors your Google Drive and sends daily email notifications with a detailed list of files that were deleted the previous day.

Here’s a sample email notification sent by the Google Drive Watch program.

Google Drive Watch Deleted Files

The email includes the file link, the date when the file was first created, and the name/email address of the Google Account that last modified and deleted the file. It monitors files in your regular Google Drive as well as Shared Drive folders.

Watch your own Google Drive

Here’s how you can set up Google Drive watch for your own Google account in few easy steps:

  1. Click here to make a copy of the Google script in your own Google Drive.

  2. Inside the script editor, go to line #9 and specify the email address where you want to receive the Drive notifications. You can also put multiple emails separated by commas.

  3. The script, by default, will create a cron job that will run once per day at the selected hour. If you however wish to change the frequency so that the notifications arrive, say, every 5 days, you can specify 5 in line #10.

  4. We are almost there. Go to the Run menu and choose “Enable Drive Watch” to enable the monitor for your Drive. Allow the script to access your file and you are all set.

Configure Google Drive Watch Email

Important: The first email notification will only arrive the next day at the selected hour.

How Google Drive Monitoring Works

The source code of the Google Drive monitor script is available on Github.

Internally, the script uses the Google Drive API with Google Apps Script to watch for changes in your Google Drive. It then sets up a daily cron job, using triggers in Google Scripts, that sends the email if new file changes are found.

When you first run the script, it gets a starting page token and all changes made to Google Drive after this token is fetched will be monitored by the script. We set supportsAllDrives to true since the script should monitor folders in Team Drives as well.

function getPageToken() {
  const store = PropertiesService.getScriptProperties();
  const token = store.getProperty('token');
  if (token) return token;
  const { startPageToken } = Drive.Changes.getStartPageToken({
    supportsAllDrives: true,
  });
  store.setProperty('token', startPageToken);
  return startPageToken;
}

The change.list endpoint of the Google Drive API fetches all changes made to the authorized user’s Drive since the start page token. We also set the fields property to limit file properties that are available in the response. The newStartPageToken returned in the response will become the new page token for future calls to the Drive API.

const fields = `newStartPageToken,
  items(file(id,title,labels(trashed),
  iconLink,mimeType,createdDate,ownedByMe,
  lastModifyingUser(emailAddress,displayName,picture(url)),
  alternateLink, fileSize))`;

const { newStartPageToken, items = [] } = Drive.Changes.list({
  fields,
  pageToken: getPageToken(),
  includeItemsFromAllDrives: true,
  pageSize: 100,
  supportsAllDrives: true,
});

if (newStartPageToken) {
  propertyStore.setProperty('token', newStartPageToken);
}

The items array holds a list of files that have been modified since the last run. This also includes new files that have added and old files that were edited by the users. Since we are only interested in the file that have been trashed, we’ll filter all files from the response except the ones that have been trashed.

const filteredItems = items
  .map(({ file }) => file)
  // Only interested in files where "I" am the owner
  .filter(({ ownedByMe }) => ownedByMe)
  // Only interested in files that have been "trashed"
  .filter(({ labels: { trashed } = {} }) => trashed === true)
  // Only return fields that are sent by email
  .map((file) => {
    const {
      iconLink,
      alternateLink,
      title,
      lastModifyingUser = {},
      createdDate,
      fileSize,
    } = file;
    return { iconLink, alternateLink, title, createdDate, fileSize };
  });

Now that we have an array of files that have been deleted by the user since the last run, we can use the Gmail service to notify the user.

Also see: Google Drive URL Tricks



from Digital Inspiration https://ift.tt/2HFWHgM

Wednesday, 21 October 2020

How to Send Emails from a Different Address (Alias) with Gmail

Say you have two email accounts - personal@gmail.com and work@company.com - the former is your personal email address while the latter is your work (corporate) email address. You are logged into your personal Gmail account but would like the mail merge to go out from your work account.

Consider another scenario where the personal secretary needs to sends out emails on behalf of her boss. So she runs the merge while staying logged into her own Google account but the recipients will see her boss’s email as the sender.

Both these scenarios can be easily handled in Mail Merge and Document Studio by setting up aliases in Gmail.

You can even send emails from your Outlook, Yahoo or Zoho email addresses through aliases in Gmail. Students and teach can send emails from their @school.edu email address while logged into their personal email accounts.

How to Setup Email Aliases in Gmail

Open gmail.com on your desktop computer, go to Settings, click the Accounts tab and, under the “Send mail as” section, click the link that says “Add another email address.”

Gmail Add Email Address

Next, follow the wizard to add the other email address as an alias to your current email address. You need to specify the sender’s name, the email address on behalf of which you wish to send out th emails and the reply-to address (optional).

Gmail Alias Setting

Treat as an alias - Yes or No?

If you own both email accounts, check the “treat as alias” option and emails sent to either address will arrive in the same Gmail inbox.

If you are sending emails on behalf on another person, say a secretary sending emails on behalf of his or her boss, the option should be unchecked. When the recipient replies to messages you send from the alias, the To: field in their reply message will be filled with your alias email address.

Gmail Verification

Gmail will send a verification code to your other email address that you wish to add as an alias to verify whether you really own or have access to that email account.

Verification Email Link

Log in to your other Gmail account and open confirmation email. Copy the confirmation code and paste it into alias verification box. Your other email address will now be added as an alias to your primary email address.

Change the Email Sender

This is how you can send emails from a different address in Google Sheets.

Mail Merge for Gmail

Send Email from Alias

Open your Google Sheet, choose Addons > Mail Merge with Attachments > Configure to open the merge sidebar. Expand the “Sender’s Email” dropdown and it will have a list of all email aliases that are connected to your Gmail account.

You can now send personalized emails on behalf of any email address that you own or have verified as an alias.

Document Studio

Open Google Sheet, go to Add-ons > Document Studio > Open. Expand the Mail Merge section and click on edit to open the Email Template designer. You’ll have an option to change the email sender as shown in the screenshot below:

Change Email Sender

Error - Cannot Add Aliases in Gmail

Are you getting an error while adding an alias in Gmail?

You must send through gmail.com SMTP servers you can send as abc@work.com. However, this functionality is not available for your account. Please contact your domain administrator.

If you do not see an option to add aliases in your Gmail settings, it is likely because your Google Workspace (GSuite) domain administrator has disabled the option to send email from aliases in domain settings.

To enable email sender aliases in Google Works, ask the admin to:

  1. Sign into the Google Admin console admin.google.com.
  2. From the dashboard, go to Apps > GSuite > Gmail > End User Access.
  3. Turn on the “Allow per-user outbound gateways” setting that says “Allow users to send mail through an external SMTP server when configuring a “from” address hosted outside your email domains.”

Save the settings and wait for about 30-60 minutes for the changes to propagate. You’ll then be able to added external email addresses as aliases in your Google Workspace email account.

Google Workspace Email Setting Send from a different email address in Google Workspace



from Digital Inspiration https://ift.tt/3jiMBjp

Saturday, 17 October 2020

How to Request Additional Quota for your YouTube API Project

A UK based organization recently organized an online conference with 300+ participants and each of the attendees were asked to upload a video to a common YouTube channel post the event. The organizers created a YouTube uploader to make it easy for attendees to submit videos but soon ran into the quota issue with YouTube.

Let me explain.

The YouTube API website says that 1600 quota units are required to upload a single video to the YouTube website through the videos.insert method of the YouTube API. Thus, for instance, if you are expecting users to upload 100 videos to your YouTube channel in a single day, your Google Cloud project should have a quota of at least 1600 * 100 = 160,000 units.

The quota limits reset every 24 hours. New Google Cloud projects have lower quota and you’ll have to request YouTube to increase your quota if you are expecting higher number of videos.

Increase your YouTube API Quota

Here’s step by step guide that will help you get your YouTube video uploader, or any other Google Apps Project, approved for higher quota.

Configure Google Cloud Project

1. Go to console.cloud.google.com/projectcreate to create a new Google Cloud Project.

Create Google Cloud Project

2. From the menu, go to APIs and Services and chose OAuth Consent Screen. Set the type as External and click the Create button.

Oauth Consent Screen

3. Give your application a name, then click the Add Scope button and specify the list of OAuth Scopes that your Google Cloud project will require. For the uploader, we require the following Google APIs:

https://www.googleapis.com/auth/youtube.readonly
https://www.googleapis.com/auth/youtube.upload
https://www.googleapis.com/auth/script.external_request
https://www.googleapis.com/auth/script.send_mail
https://www.googleapis.com/auth/userinfo.email

OAuth Consent screen

4. Inside the API and Services section, choose Library, search for the YouTube Data API library and click Enable to enable the library for your project.

Enable YouTube API

5. Click the 3-dot menu in the upper right, choose Project Settings and make a note of the project number of your Google Cloud Project.

Google Cloud Project

Configure Google Apps Script

1. Open your Google Script, go to the Resources menu, choose Cloud Platform project and enter the project number that you have copied in the previous step.

Link Cloud Project with Apps Script

Click the “Set Project” button to link your Google Cloud Project to your Google Apps Script Project.

2. Go back to the Google Cloud project, click the API and Services section, choose Credentials and copy the OAuth client ID to the clipboard.

OAuth Client ID

Request YouTube to Increase Quota

Now that you have all the necessary data, it is time to submit your YouTube project to Google for increasing your API quota. Open this request form and fill the required details.

The API client is the same as the OAuth Client ID that you copied in the previous step. The project number is the same as your Google Cloud Project number. For the “Where can we find the API client” question, you need to provide the link of your YouTube uploader form.

Submit the form and you’ll receive a response from Google Compliance team saying they are conducting an audit.

Thanks for your response to the Quota Request. We will conduct our audit based
on the information you provided. We will notify you if additional information is
needed or when we’ve completed our review. Thank you for your cooperation.

They may have some follow-up questions and once they grant the quota (usual takes 3-4 days), you’ll receive a confirmation.

Your quota extension request has been approved based on the information you
provided and your representation that your use of YouTube API Service are in
full compliance with the YouTube API Services Terms of Service. The total quota
for project 123 is now 500,000 units / day. Please note that the quota extension
has been granted ONLY for the use-case mentioned in your quota extension request
application and we may change your quota based on your actual quota usage as
well as on your continued compliance with the YouTube API Services Terms of
Service at any time.


from Digital Inspiration https://ift.tt/2H7Y4op

How to Password Protect Google Documents and PDF files in Google Drive

Introducing PDF toolbox, a new Google Drive addon that lets you password protect PDF files and Google Documents. The app can also help you unlock PDF files that are already protected with a password in your Google Drive.

Watch the video tutorial to get started.

Password Protect PDF Files

To get started, install the PDF toolbox add-on and grant the necessary authorization. The app requires access to the file that you would like to encrypt (or decrypt) and you also have an an option to send the encrypted file as an email attachment to another user.

Next, select any PDF file or Google document in your Google Drive and expand the “Encrypt PDF” section. Enter the output file name (it will also be saved in your Google Drive), provide a password and specify whether the encrypted file should allow printing and comments.

Click the Encrypt button to create a new PDF file that would require a password to open.

Password protect PDF files

The app can secure PDF files as well as Google documents, spreadsheet and presentations. In the case of native Google documents, the file is first converted to a PDF document and then encrypted with the specified password.

Please note that the Google Drive API imposes a limit of 10 MB on the size of PDF files exported from native Google documents. Thus, similar restrictions apply with the toolbox as well.

Unlock PDF files

If you a password-protect PDF file in your Google Drive, you can use the PDF toolbox to remove the password protection. The app will create a new copy of the PDF file in your Drive that will open without requiring a password.

The workflow is similar.

Select any locked PDF in Google Drive and open the PDF toolbox app in the sidebar. Expand the “Decrypt PDF” section and and type the password that was originally used to restrict access to the PDF file.

Click the Decrypt button and, if the password matches, all restrictions would be removed from the file. The unlocked, password-free PDF file would be uploaded to Google Drive as a separate file.

Remove PDF Password

How PDF toolbox works

All files in Google Drive have an export link to download the file in PDF format. The app uses the export URL to fetch the PDF version of a file in Google Cloud storage, encrypts (or decrypts) the file with the PDF library and uploads the processed file to Google Drive of the authorized user.

All downloaded files are instantly removed from the cloud storage after the PDF file has been exported. PDF toolbox is in beta stage and the pricing will be added later this month.

Also see: Remove PDF Passwords with Chrome



from Digital Inspiration https://ift.tt/2T2z2K1

Thursday, 15 October 2020

Reclaim Disk Space - How to Find the Biggest Files in your Google Drive

Your Google account storage is shared between Gmail, Google Drive, and Google Photos. What do you do when your Google account is running out of storage space? You either buy more storage from Google or the inexpensive option is that you spend some time spring-cleaning your account and delete the emails and files that could be hogging up the storage space.

Recover Spaces in Google Drive

First things first. Go to google.com/settings/storage and click on the “View Details” link to know the total available disk space and see exactly how much storage space is used by the email and drive service.

Gmail offers the size search operator so you can easily find emails that have large attachments and delete them to reclaim space. For instance, a query like size:5MB older_than:1y will show all emails older than a year and that take up more than 5 MB of space in your Google account. See more Gmail search operators

Unlike Gmail, there’s no easy way to find large files by size in Google Drive but there’re some easy workarounds to find the big files in your Google account.

For Gmail accounts

If you have a @gmail Google account, go to one.google.com and click the “review” link under Large Files.

Google Drive Large Files

You’ll get a sorted list view of all files in your Google Drive, sort by size. Select the ones you no longer need and hit the delete button to instantly recover space.

Please note that files deleted from the Storage manage inside Google One are permanently deleted and can no longer be recovered.

For GSuite (Google Workspace) accounts

GSuite is now Google Workspace and, apart from rebranding, Google no longer offers unlimited Drive storage that was earlier available with the GSuite Business plan. The Enterprise plans do not impose any storage limits.

To reclaim space in Google Drive for GSuite accounts, open this link drive.google.com/drive/quota and you’ll get a list of all files in your Google Drive arranged from largest to smallest size

You can remove the files that you no longer need but there’s one extra step. Google Drive will move the files to the trash bin so you’ll have to empty the bin as well to reclaim space.

The Google Drive files list only includes non-native file formats since the native Google files - like Google Documents or Google Sheets - do not take any storage space on your Google Drive.

Tip: Use the Drive Auditor to get a detailed report of all Google Drive files that can be sorted by size in Google Sheets.

Delete App Backups

In addition to binary files, certain apps may be using your Drive Storage for storing files and app settings. You cannot explore the individual files that are stored by apps in your Google Drive but you do have an option to delete the data stored by them in your Drive.

Inside Google Drive, go to settings, and choose Manage Apps. Click the options button against the app name and choose “Delete hidden data”.

Google Drive - Hidden App Data

You may also want to check the Backups section in your Google Drive (google.com/drive/backups) that stores backup of your Android phone, app settings and WhatsApp messages. They take up space as well but Google Drive doesn’t specify the exact size of backups.

Also see: Save Gmail to Google Drive



from Digital Inspiration https://ift.tt/2eVm7Zw

Sunday, 11 October 2020

How to Make your Documents Read-only in Google Drive

The files in your Google Drive are private by default and only the owner has initial permissions to view, edit or delete their files. If you choose to share a file with other people, you can decide whether others have read-only access to your files or if they are allowed to edit and comment on your files.

You can always remove external collaborators from your documents to prevent them from editing your files but how do you prevent yourself (the owner) from accidentally editing your own files in Google Drive?

Locked Google Drive File

How to Prevent Document Edits in Google Drive

Google Drive now has a new Locking API to help developers easily add content restrictions on documents, spreadsheets, presentations, PDF and any other file in Google Drive.

When you lock a file, no one (including the owner) can make edits to the file, the file title cannot be changed and also lose the option of commenting inside files.

Google Drive doesn’t have a simple button (yet) for locking files so here’s a little Google Script that can help you make any file in your Google Drive read-only.

1. Open Google Drive and right-click any file that you wish to make a read-only file. Click the Share Link menu and copy the file link to the clipboard.

https://docs.google.com/spreadsheets/d/12345_abcdef-123/edit?usp=sharing

2. Type script.new in the browser to open a new Google Apps Script project and copy-paste this snippet in the code editor.

/**
 *  Make Google Drive files Read only
 *  Author: amit@labnol.org
 *  Web: https://digitalinspiration.com/
 *  MIT License
 **/
const makeFileReadyOnly = () => {
  const fileUrl = '<<FILE URL>>';
  const [fileId] = fileUrl.split('/').filter((e) => /[_-\w]{25,}/.test(e));
  UrlFetchApp.fetch(`https://www.googleapis.com/drive/v3/files/${fileId}`, {
    method: 'PATCH',
    contentType: 'application/json',
    headers: {
      Authorization: `Bearer ${ScriptApp.getOAuthToken()}`,
    },
    payload: JSON.stringify({
      contentRestrictions: [
        {
          readOnly: true,
          reason: 'Prevent accidental editing',
        },
      ],
    }),
  });
  // For requesting correct scope, do not delete
  // var file = DriveApp.getFileById().setName()
};

3. Replace the FILE URL in line #2 with the URL of the Drive file that you copied in the previous step.

4. Go to the Run menu, choose Run function > makeFileReadyOnly. Accept the permissions and your file will restricted from editing by anyone including yourself.

If you would like to remove the file lock and allow editing, open Google Drive, right click the same file and choose “Unlock file” from the menu to restore the editing behavior.

Also see: URL Tricks for Google Drive

Unlock Google Drive File

Please do note that when you freeze a document with the Google Drive Lock API, even Google Scripts and Google Workspace add-ons are blocked from editing the file.



from Digital Inspiration https://ift.tt/3iMthKP