Pull business card from Outlook Contact into Attachment (or OLE) field in Access with VBA

Posted on 2011-04-19
Last Modified: 2012-05-11
Due to 8 years of mis-managed contacts, I am trying to clean up a clients contacts.  There is no way I can see to do this (due to the mess it is in, over 5,000 contacts with wrong data in wrong fields, company names spelled differently in multiple contacts, etc.).  So I am trying to bring all his info into Access where I can 1) store a back-up of his contacts with all information, that I can easily manipulate 2) clean-up contacts and re-import into Outlook.

However, I do not know how to grab an attachment with a contact (ie: business card) and bring it into an access field set as either "attachment" or "OLE" (I am dealing with Access and Outlook 2010)
Question by:MsSherryG
    LVL 15

    Accepted Solution

    not an expert in this field, but there used to be a way to export contracts to excel ( fromwhich you could impor them to access....

    google reveals a way in O2010

    would that help?

    if these are all attachments then probably going to have to use access automation to open outlook and go through messages to check for attachments... google again...

    could use this:

    to have access open outlook, performthe attachment check, then save it and import it into access.

    there might be a better way to grab the data from the attachment.

    i've not got O or A2010 yet so cannot help with the specifics..


    Author Comment

    Thanks Sudonim, I take a look at these links.  All I need to pull in is contact info, and I already have the code to pull  all the info into an access table, the only field I am having trouble with is bringing in the business card if there is one attached.  The plan is to completely reimport all contacts from Access once they are standardized and cleaned up, but he doesn't want to loose the business card attachment if there is one.  (some of his contacts came from him scanning in business cards, which then retains a copy of the card as an attachment to the contact.)

    But again... thanks, I'll take a look at the code now.

    Author Comment

    Sudonim - Thanks for your assistance, unfortunately none of these links tell me what I need to know (although the second link is very handy as I can see a use for that in the future.)  So again, thanks but still not what I'm needing.
    LVL 15

    Expert Comment

    by:Simon Ball
    sorry i mssed that so these are cards as an attachement to the contact.

    should be possible to iterate though contacts and check for attachments, then use whatever you currently use to export / import them.

    in my outlook 2007 contacts view, a lot of my phone synched facebook cntacts have an attachment symbol which is their business card.

    i wonder if the contact item treats the buscard as an attachment.

    afraid i am out of my depth here then, we need a proper Outlook pro to crack this one :(



    Author Comment

    No Problem Sudonim - Thanks for your help.  I've been trying several different syntax to grab attachment but it doesn't like any of them.
    LVL 15

    Expert Comment

    by:Simon Ball
    is there a way to loop through the properties of a contact and get the names?

    like in access i would loop through a container / collection  like

    dim dbs as database
    set dbs = currentdb

    dim tbl as tabledef
    for each tbl in dbs.tabledefs


    Assisted Solution

    yep, I did that.  There is an "attachments" property, but for one thing it is one of the new multi-valued fields, but also all I am finding is code that shows how to save an attachment to a file on the pc, or bring an attachment in from a file on pc.  Just haven't found the time to write that code (I'm not an expert so it takes me a little more time to write code like that :) ... but perhaps, if I really want to get the attachment into Access, that may be what I will have to do... loop through contacts, save attachment to file on my pc, then writing code to bring that file off of pc into Access.  Just was hoping for a direct way to copy it straight from Outlook to Access with the rest of contact info.
    Too much to do... too little time :)


    Author Closing Comment

    I ended up doing a work around.  I used the "saveasfile" outlook function to save the attachments to a file on my pc, and added a field in Access table that was marked as true if a file was saved for a certain contact.  I then looped back through recordset and used the loadfromfile method to pull the file back into the attachment field in my access table.

    It wasn't pretty, but it got the job done.  Anyway, I now have a better grasp on how to load files into the multi-value fields (such as attachments) in Access 2010.

    Sudonim - Thanks for your assistance.  Your information was useful and your time appreciated.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
    Outlook Free & Paid Tools
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now