Gists
Abstract A new library, MimeTypeApp, simplifies using Gmail messages and attachments with the Gemini API for tasks like text analysis. It converts unsupported formats for seamless integration with Google Apps Script and Gemini.
Introduction Recently, I published MimeTypeApp, a Google Apps Script library that simplifies parsing Gmail messages, including attachments, for use with the Gemini API. Ref This library addresses a key challenge: Gmail attachments come in various MIME types, while the Gemini API currently only accepts a limited set for processing.
Gists
Abstract This report improves Gmail email labeling with Gemini API using JSON schema and leverages advancements in Gemini 1.5 Flash for faster processing.
Introduction As Gemini continues to evolve, existing scripts utilizing its capabilities can be revisited to improve efficiency and accuracy. This includes the process of flexible labeling for Gmail emails using the Gemini API. I have previously explored this topic in two reports:
December 19, 2023: Demonstrating Gmail label selection based solely on prompts.
Gists
This is a sample script for searching Gmail messages by Gmail Filters using Google Apps Script.
At Gmail, users can set the filter for the Emails. With this filter, users can filter the Emails of Gmail. But, when the users want to search by the installed filter using Google Apps Script, unfortunately, it seems that this cannot be directly achieved. For example, messages cannot be searched using a filter ID.
Gists
This is a workaround for converting a Gmail message to a PNG image using Google Apps Script.
Sample script Please set the message ID of Gmail.
function myFunction() { var id = "###"; // Please set your message ID of Gmail. var message = GmailApp.getMessageById(id); var date = Utilities.formatDate( message.getDate(), Session.getScriptTimeZone(), "yyyy-MM-dd HH:mm:ss" ); var from = message.getFrom(); var to = message.
Gists
This is a sample script for sending multiple emails using the batch request with Gmail API using Google Apps Script. When multiple emails are sent using “GmailApp.sendEmail” and “MailApp.sendEmail”, a loop is used. But in this case, the process cost becomes high. In this post, I would like to introduce the sample script for reducing the process cost under this situation. Gmail API can be requested with the batch request.
Gists
This is a sample script for sending Gmail with the title and body including Emoji using Google Apps Script.
Sample script This sample script uses Gmail API. So please enable Gmail API at Advanced Google services. Ref
const convert_ = ({ to, emailFrom, nameFrom, subject, textBody, htmlBody }) => { const boundary = "boundaryboundary"; const mailData = [ `MIME-Version: 1.0`, `To: ${to}`, nameFrom && emailFrom ?
GmailToList was updated to v1.0.1. v1.0.1 (December 17, 2019)
New method of getAttachmentFiles() was added. The attachment files can be retrieved as blob using this method. You can see the detail information here https://github.com/tanaikech/GmailToList
Overview This is a library for exporting all messages of Gmail as a list using Google Apps Script (GAS).
Description Recently, I have had a situation it had been required to backup all messages in own Gmail. In order to achieve this, I created a simple script. After I created it, I thought that when such situation might occur for other users and the script is published as a library, they might be useful.
Gists
These are sample scripts for adding a label to a message using message ID for Gmail.
Sample 1 This sample adds a label to a thread using message ID. In this case, all messages in the thread have the label. Even if it adds a label to a message in the thread using addLabel(), all messages in the thread have the label, becauce addLabel can only be used for the thread.
Gists
Description : This sample script is for retrieving emails which replied for received mails. Because there are no samples which confirm whether the owner (me) replied to the received mails, I created this. The point is as follows.
When there are more than 2 messages in a thread, there might be a possibility to have replied. For more than 2 messages in a thread The email address of “from” for the 1st message is the sender’s address.
Gists
This is a sample script for sending e-mails from gmail using Nodemailer. In order to use this, please retrieve the folloing parameters before run this script.
gmail address client ID client Secret Refresh token Please include https://mail.google.com/ in the scope. Enable gmail API at API console. Install Nodemailer const nodemailer = require('nodemailer'); var auth = { type: 'oauth2', user: '### your gmail address ###', clientId: '### client ID ###', clientSecret: '### client secret ###', refreshToken: '### refresh token ###', }; var mailOptions = { from: '#####', to: '#####', subject: 'sample subject', text: 'sample text', html: '<b>sample html</b>', }; var transporter = nodemailer.
Gist
This is a sample script for decoding Gmail body with Japanese language using Python.
msg = service.users().messages().get(userId='me', id=id).execute() parts = msg['payload']['parts'] for e in parts: msg = base64.urlsafe_b64decode(e['body']['data']).decode('utf-8').encode('cp932', "ignore").decode('cp932') print(msg)