Skip to content

Instantly share code, notes, and snippets.

@thumblemonks
Created February 9, 2010 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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