fileoutlookexportcontactspublic-folders

MS Exchange / Outlook; contacts import / export including embedded files via C#


We have a public contacts folder called Global Contacts on our Exchange 2003 server.

We are currently building an SQL Server-based system that will replace this. There is a WinForms front end written in C# for this that is mostly written already.

Somehow we need to ship all the contacts from Global Contacts over to our new SQL Server tables. My current plan is to just export the folder to an Excel file and import that into SQLS (I have a load of code written in C# to talk to Excel already so I can deal with the mapping pretty easily).

The problem comes with files that are 'embedded' in the comments section of the contacts - obviously these will not be exported when I rip Global Contacts out to an Excel file. Often people have dragged and dropped e.g. excel price lists, emails etc into there. I need a way of bulk exporting them, yet somehow retaining info on which contact they came from.

Can anyone point me in the right direction as to how to get those 'embedded' files via C# (or any other [easier] way for that matter, it would be nice if I didn't have to spend time reinventing the wheel)?


Solution

  • In the end I was able to get attachments like so:

    foreach (Outlook.Attachment o in itmsFiltered[i].Attachments)
    {
        try
        {
            o.SaveAsFile(strPath + o.FileName);
        }
    }