Note that there are some explanatory texts on larger screens.

plurals
  1. POModifying Microsoft Outlook contacts from Python
    primarykey
    data
    text
    <p>I have written a few Python tools in the past to extract data from my Outlook contacts. Now, I am trying to <em>modify</em> my Outlook Contacts. I am finding that my changes are being noted by Outlook, but they aren't sticking. I seem to be updating some cache, but not the real record.</p> <p>The code is straightforward.</p> <pre><code>import win32com.client import pywintypes o = win32com.client.Dispatch("Outlook.Application") ns = o.GetNamespace("MAPI") profile = ns.Folders.Item("My Profile Name") contacts = profile.Folders.Item("Contacts") contact = contacts.Items[43] # Grab a random contact, for this example. print "About to overwrite ",contact.FirstName, contact.LastName contact.categories = 'Supplier' # Override the categories # Edit: I don't always do these last steps. ns = None o = None </code></pre> <p>At this point, I change over to Outlook, which is opened to the Detailed Address Cards view. </p> <p>I look at the contact summary (without opening it) and the category is unchanged (not refreshed?). </p> <p>I open the contact and its category HAS changed, <em>sometimes</em>. (Not sure of when, but it feels like it is cache related.) If it has changed, it prompts me to Save Changes when I close it which is odd, because I haven't changed anything in the Outlook UI.</p> <p>If I quit and restart Outlook, the changes are gone.</p> <p>I <em>suspect</em> I am failing to call <a href="http://msdn.microsoft.com/en-us/library/cc842181.aspx" rel="noreferrer">SaveChanges</a>, but I can't see which object supports it.</p> <p>So my question is:</p> <ul> <li>Should I be calling SaveChanges? If so, where is it?</li> <li>Am I making some other silly mistake, which is causing my data to be discarded?</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload