Created
May 10, 2011 13:24
-
-
Save bcoe/964461 to your computer and use it in GitHub Desktop.
Gmail Message ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _get_email_uuid(self, message_id): | |
try: | |
typ, data = self.connection.fetch(message_id, '(X-GM-MSGID)') | |
# 1 (X-GM-MSGID 1363378113778197832) | |
mid_regex = re.compile(r'^.* \(.* ([0-9]*)\)$') | |
match = mid_regex.match(data[0]) | |
if match: | |
raw_hex = hex( int( match.group(1) ) ) | |
# 0x12ebb12bc64aa548L | |
hex_regex = re.compile(r'^[0-9]x([0-9a-f]+)L$') | |
match = hex_regex.match(raw_hex) | |
if match: | |
return match.group(1) | |
except Exception, e: | |
self.user.logger.error("Could not get message id for %s from %s." % ( | |
message_id, | |
self.user.email | |
)) | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment