Skip to content

Instantly share code, notes, and snippets.

@beny
Created July 20, 2012 15:16
Show Gist options
  • Save beny/3151278 to your computer and use it in GitHub Desktop.
Save beny/3151278 to your computer and use it in GitHub Desktop.
simple script, which finds Notes from iOS app in my Gmail
require "net/imap"
require "mail"
=begin
SAMPLE zpravy
Subject: =?utf-8?Q?Kv=C4=9Btin=C3=A1=C5=99stv=C3=AD_D=C4=9Bl=C5=88=C3=A1k?=
From: =?utf-8?Q?Ondra_Bene=C5=A1?= <steve.jobs@gmail.com>
X-Universally-Unique-Identifier: DDC4E35E-7D70-4E97-8167-011B204229D3
Content-Type: text/html;
charset=utf-8
X-Uniform-Type-Identifier: com.apple.mail-note
Message-Id: <C71FF265-01F5-4630-9868-F946E2DD602B@gmail.com>
Date: Mon, 25 Jun 2012 17:47:46 +0200
X-Mail-Created-Date: Mon, 25 Jun 2012 17:47:46 +0200
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (1.0)
Kv=C4=9Btin=C3=A1=C5=99stv=C3=AD D=C4=9Bl=C5=88=C3=A1k<div><br></div><div>Po=
-P=C3=A1 9-17</div><div>So 8-11</div>=
=end
imap = Net::IMAP.new("imap.gmail.com", 993, true, nil, false)
imap.login("steve.jobs", "supersecret")
puts "Logged in"
imap.select("[Gmail]/All Mail")
puts "In folder"
imap.search(["All"]).each do |mail|
if imap.uid_fetch(mail, 'RFC822') == Array
mail = Mail.new imap.uid_fetch(mail, 'RFC822').first.attr['RFC822']
p mail.header["X-Uniform-Type-Identifier"] if mail.header["X-Uniform-Type-Identifier"] == "com.apple.mail-note"
end
end
puts "Search done"
@vicjang
Copy link

vicjang commented Jan 24, 2016

I can't tell you how happy I am when I see this!
The note corpses in my gmail account is about to drive me crazy, I think I can delete them all at once with a little modification.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment