Sync Microsoft Outlook with my own data?

醉酒当歌 提交于 2019-12-19 11:54:37

问题


Using VB.Net, I need to read data from a Microsoft Outlook 2007 PST file and an external database, and sync the two sources.

Past posts on SO mention Microsoft.Office.Interop.Outlook. I was wondering if VB.Net developers had successfully used this to work with Outlook, or if there were other solutions I should try instead.

Thank you.


回答1:


If you really talk about "synchronization" then you should take a look at Microsoft Sync Framework. http://msdn.microsoft.com/en-us/sync/default

This framework helps out with everything that relates to synchronization, what happens when same data has changed in both places, and so on. And they have lots of "providers", for example Outlook are one "provider" that you can use to synk items between your own data and outlook.

Contact Synchronization Sample (C#)

From msdn:
This sample shows how custom providers can be created to synchronize content between disparate data sources. In this sample we will synchronize Contacts between Microsoft Outlook, Vista Contacts and VCard files. A key aspect of this demo is the data mapping capabilities which enables disparate data sources and data types to be mapped appropriately through the Sync Framework

http://archive.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=613

Or the good old way...:
If you just want to add some contact or meeting then the old office interopt is good enough, here are an quick example, 11 rows of code to add a contact:

    Dim OutlookApp As Outlook.Application = New Outlook.Application
    Dim OutlookNameSpace As Outlook.NameSpace = OutlookApp.GetNamespace("MAPI")
    OutlookNameSpace.Logon()

    Dim Contacts As Outlook.MAPIFolder = OutlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

    Dim newContact As Outlook.ContactItem = OutlookApp.CreateItem(Outlook.OlItemType.olContactItem)
    newContact.FullName = "Stefan Karlsson"
    newContact.Email1Address = "myemail@mail.com"
    newContact.BusinessHomePage = "www.example.com"
    newContact.Save()

    OutlookApp.Logoff()
    OutlookApp.Quit()

(You have to add reference to Microsoft.Office.Interop.Outlook and add this imports to your code for the example to work)

Imports Microsoft.Office.Interop




回答2:


You may also find helpful a free Outlook add-in used for synchronizing Outlook and Gmail accounts and contacts: http://scand.com/products/outlook4gmail/index.html. I found it a week ago and have been using ever since for Outlook 2007, though it can be used for Outlook 2010 as well. The features are really useful.



来源:https://stackoverflow.com/questions/5372267/sync-microsoft-outlook-with-my-own-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!