the-generalist.com

  • Increase font size
  • Default font size
  • Decrease font size
joomla templates, wordpress themes, drupal, datalife engine, graphics, seo,
Home

Adding Eve Contacts to Microsoft Outlook

E-mail Print PDF

I wrote this as a proof of concept. I don't know if it has a useful application, but I'd be willing to develop it into a full tool if there is any interest. I'm posting the example code for anyone who happens to be interested though. For this to work, you need to install pyWin32 and run makepy on the Microsoft Outlook 14.0 Object Library (explained in the linked article). Now keep in mind if you run this, it's not currently designed to do merging or error checking. If you run it twice, you get two copies of the characters. If you already have contacts in Outlook, these will merge with them. I'm really just posting it in case someone has a good idea for it.

import urllib
import xml.dom.minidom
import win32com.client
 
#This function grabs the text from a node.
def getText(node):
    for childNode in node.childNodes:
        if childNode.nodeType == childNode.TEXT_NODE:
            return childNode.data
 
#This function finds all the characters in a contact API list
#and adds them to the Characters dictionary that's passed in
def parseContactAPI(downloadedData, Characters):
    XMLData = xml.dom.minidom.parse(downloadedData)
    headerNodes = XMLData.getElementsByTagName("rowset")
    for headerNode in headerNodes:
        dataNodes = XMLData.getElementsByTagName("row")
        for dataNode in dataNodes:
            characterID = int(dataNode.attributes['contactID'].value)
            if not characterID in Characters:
                newCharacter = Character()
                newCharacter.CharacterID = characterID
                newCharacter.CharacterName = dataNode.attributes['contactName'].value
                newCharacter.Standing = float(dataNode.attributes['standing'].value)
                Characters[characterID] = newCharacter
 
#Class to hold the character information
class Character:
    def __init__(self):
        self.CharacterID = None
        self.CharacterName = None
        self.Standing = None
        self.CorporationID = None
        self.AllianceID = None
        self.CorporationName = None
        self.AllianceName = None
 
#Enter your UserID and API Keys here
UserID = 'XXXXXXX'
Key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
CharacterID = 'XXXXXXXXXX'
 
#I'm going to store the characters in a dictionary.
#I use a dictionary to help me prevent duplicates.
Characters = {}
 
#Download the corporation contact list
apiURL = 'http://api.eve-online.com/corp/ContactList.xml.aspx?userid=%s&apikey=%s&characterid=%s' % (UserID, Key, CharacterID)
downloadedData = urllib.urlopen(apiURL)
parseContactAPI(downloadedData, Characters)
 
              
#Download your personal contact list
apiURL = 'http://api.eve-online.com/char/ContactList.xml.aspx?userid=%s&apikey=%s&characterid=%s' % (UserID, Key, CharacterID)
downloadedData = urllib.urlopen(apiURL)
parseContactAPI(downloadedData, Characters)
 
#For each of the characters, get the character info so we can get the corporation
#I included a try in this case in case there's a failure to get one of the contacts.
#This way the whole script doesn't die, you just don't get that character's corporation.
for contactCharacterID, character in Characters.items():
    try:
        #Download the Character data
        apiURL = 'http://api.eve-online.com/eve/CharacterInfo.xml.aspx?characterid=%s' % (contactCharacterID)
        downloadedData = urllib.urlopen(apiURL)
          
        #Grab the corporation data
        XMLData = xml.dom.minidom.parse(downloadedData)
        dataNodes = XMLData.getElementsByTagName("result")
        for dataNode in dataNodes:
            corpElem = dataNode.getElementsByTagName("corporation")
            character.CorporationName = getText(corpElem[0])
 
    except:
        print 'skip %s' % character.CharacterName
 
#Connect to Outlook
Outlook = win32com.client.Dispatch("Outlook.Application")
 
#Go through the list of characters.
for CharacterID, Character in Characters.items():
 
    #Create a new Contact and save it
    NewContact = Outlook.CreateItem(win32com.client.constants.olContactItem)
    NewContact.FullName = Character.CharacterName
    NewContact.CompanyName = str(Character.CorporationName)
    NewContact.Save()

Last Updated on Wednesday, 06 July 2011 14:44  

Comments  

 
0 #7 gas em osasco 2017-11-08 13:44
Tele Entrega Gás Rápida, Segura e também Garantida.
Quote
 
 
0 #6 vapor barrier 2017-09-13 20:53
I every time used to read piece of writing in news papers but now as I aam
a userr of web so frolm now I am using net for content,
thanks to web.
Quote
 
 
0 #5 Inge 2017-08-22 04:07
Now my weight appears to be in free fall.
Quote
 
 
0 #4 Benito 2017-07-23 18:25
Todo mundo os quartos dispõem de wi-fi e também avarandado privativa.
Quote
 
 
0 #3 viral news sites 2017-07-16 12:48
"YOU DON'T DO THAT TO ME!!!!!" Ang bagong sigaw ng bayan HAHAHA
Quote
 
 
0 #2 João Emanuel 2017-03-29 11:33
Esse currículo, conquanto, está bastante longe de incluir os êxitos, as derrotas, as
alegrias, as tristezas e as lutas inerentes à carreira da exclusivamente casal
portuguesa feminina de volei de praia que conseguiu apuramento para uns Jogos Olímpicos (Cristina Pereira/Mª José Schuller).
Quote
 
 
0 #1 web hosting and seo 2017-01-27 23:54
Wow that was unusual. I just wrdote an really long
comment but after I clicked submit my comment didn't
appear. Grrrr... well I'm not writing all that over again. Anyway, just wwanted to say superb
blog!
Quote
 

Add comment


Security code
Refresh

Main Menu