Skip to content

Instantly share code, notes, and snippets.

@yepher
yepher / .gs
Created March 11, 2024 23:06
Google Sheet, count number of message out of first 760 messages that use outlook compatibility in the body
function countEmails() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.clear(); // Clear the sheet before writing new data
sheet.appendRow(["Total Emails", "HTML Emails", "Text Emails", "[if (mso) in HTML"]);
// Fetch emails from the Inbox
const threads = GmailApp.getInboxThreads();
let totalEmails = 0;
let htmlEmails = 0;
let ifMsoEmails = 0;
@yepher
yepher / DNSClient.java
Last active March 20, 2021 13:31
Simple UDS DNS Request/Response
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
/**
@yepher
yepher / SparkPost_basic_send.json
Created May 3, 2016 16:14
SparkPost basic transmission example
{
"recipients": [
{
"address": {
"email": "test@example.com"
}
}
],
"content": {
"reply_to": "areplyto@hotmail.example.com",
@yepher
yepher / SparkPost_korean.json
Created May 3, 2016 16:13
SparkPost Transmission UTF-8 example
{
"recipients": [
{
"address": {
"email": "test1@example.com",
"name" : "크리스"
}
},
{
"address": {
@yepher
yepher / SparkPost_bcc.json
Created May 3, 2016 14:21
SparkPost BCC JSON Example
{
"recipients": [
{
"address": {
"email": "to_user@example.com"
}
},
{
"address": {
"email": "bcc_user@example.com",
@yepher
yepher / SendEmailSample.java
Created May 3, 2016 14:19
SparkPost BCC with Java Library
package com.sparkpost.samples;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
@yepher
yepher / SparkPost_dynamic_html.json
Created May 3, 2016 14:08
SparkPost Dynamic HTML chunk Example
{
"substitution_data": {
"dynamic_html" : {
"my_html_chunk" : "<p><a href = \"http://www.example.com?q={{username}}\">Click here</a></p>"
}
},
"recipients": [
{
"address": {
"email": "test@example.com"
@yepher
yepher / SparkPost_loop_substitution_vars.json
Last active May 3, 2016 14:14
SparkPost Demonstrate looping through substitution variables
{
"recipients": [
{
"address": {
"email": "recipient1@example.com"
},
"substitution_data": {
"files_html": [
{
"file": "<a href=\"http://example.com/file1a.txt\">File 1a Descrption</a>"
@yepher
yepher / cc_template.json
Last active October 18, 2016 16:47
SparkPost CC with Templates
{
"recipients":[
{
"address":{
"name":"To Recipient",
"email":"to_test@example",
"header_to":"to_test@example"
}
},
{
@yepher
yepher / SendEmail.java
Last active November 20, 2020 05:33
SparkPost Send Email directly with JavaMail (SMTP)
package javamail_rfc822_example;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;