Skip to content

Instantly share code, notes, and snippets.

@thumblemonks
Created February 9, 2010 01:14
Show Gist options
  • Save thumblemonks/298800 to your computer and use it in GitHub Desktop.
Save thumblemonks/298800 to your computer and use it in GitHub Desktop.
# A snippet from gmail/message.rb
def label(name)
@gmail.in_mailbox(@mailbox) do
begin
@gmail.imap.uid_copy(uid, name)
rescue Net::IMAP::NoResponseError
raise Gmail::NoLabel, "No label `#{name}' exists!"
end
end
end
def label!(name)
@gmail.in_mailbox(@mailbox) do
begin
@gmail.imap.uid_copy(uid, name)
rescue Net::IMAP::NoResponseError
# need to create the label first
@gmail.create_label(name)
retry
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment