Created
December 5, 2014 13:38
-
-
Save jelly/5664f87caf17d79f75ee to your computer and use it in GitHub Desktop.
AddKeyword
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
import MAPI | |
from MAPI.Util import * | |
from MAPI.Time import * | |
from MAPI.Tags import * | |
from MAPI.Struct import * | |
from plugintemplates import * | |
class addKeyword(IMapiDAgentPlugin): | |
def PostDelivery(self, session, addrbook, store, folder, message): | |
PS_INTERNET_HEADERS = DEFINE_OLEGUID(0x00020386, 0, 0) | |
NAMED_PROPS_INTERNET_HEADERS = [MAPINAMEID(PS_INTERNET_HEADERS, MNID_STRING, u'x-original-to'),] | |
namedprop_ids = message.GetIDsFromNames(NAMED_PROPS_INTERNET_HEADERS, 0) | |
namedprop_id = CHANGE_PROP_TYPE(namedprop_ids[0], PT_UNICODE) | |
prop = HrGetOneProp(message, namedprop_id).Value | |
elements = prop.split('-', 2) | |
if(len(elements) == 2): | |
try: | |
subelem = elements[1].decode('utf-8').split('@'); | |
message.SetProps([SPropValue(namedprop_id, [subelem[0]])]) | |
message.SaveChanges(0) | |
except: | |
self.logger.logFatal(sys.exc_info()[0]) | |
return MP_CONTINUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment