Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert contactitems from access to outlook

Posted on 2003-11-26
7
Medium Priority
?
553 Views
Last Modified: 2012-06-27
I've run into a problem
This export the items from access to outlook. My problem is I do not wat to export the items to the default folder of outlook but to a custom folder the I have made myself.
The foldername is Quick and it is in the root of my outlook today, type is contact items
How do I do this.
Thanx to ansvers

Private Sub Convert_outlook_Click()

' Maak DAO Objects.
   Dim oDataBase As DAO.Database
   Dim rst As DAO.Recordset
   Set oDataBase = CurrentDb
   Set rst = oDataBase.OpenRecordset("vrijwilligers")

' Maak Outlook Objects.
   Dim ol As New Outlook.Application
   Dim olns As Outlook.Namespace
   Dim cf As Outlook.MAPIFolder
   Dim c As Outlook.ContactItem
   Dim Prop As Outlook.UserProperty
   Dim lngPosition As Long
   Dim varReturn As Variant
   
   lngCount = rst.RecordCount
   strMessage = lngCount & " contact Adressen overzetten naar Outlook -- doen?"
   lngResult = MsgBox(strMessage, vbYesNo, "beginnen?")
      'Exit if user says No
   If lngResult = vbNo Then Exit Sub
   strMessage2 = lngCount & " Adressen te gaan"
   varReturn = Application.SysCmd(acSysCmdInitMeter, strMessage2, lngCount)
   Set olns = ol.GetNamespace("MAPI")
   Set cf = olns.GetDefaultFolder(olFolderContacts)
   'GetDefaultFolder(olFolderContacts)
   i = 1
   With rst
      .MoveFirst

' doorloop de accessdatabase.
      Do While Not .EOF
      For lngPosition = 1 To lngCount

' Maak een nieuw contactitem.
         Set c = ol.CreateItem(olContactItem)

         ' Specify which Outlook form to use.
         ' Change "IPM.Contact" to "IPM.Contact.<formname>" if you've
         ' created a custom Contact form in Outlook.
         c.MessageClass = "IPM.Contact"

         ' Create all built-in Outlook fields.
         If ![sx] <> "" Then c.Title = ![sx]
         If ![Voornaam] <> "" Then c.FirstName = ![Voornaam]
         If ![Achternaam] <> "" Then c.LastName = ![Achternaam]
         If ![straat] <> "" Then c.HomeAddressStreet = ![straat]
         If ![gemeente] <> "" Then c.HomeAddressCity = ![gemeente]
         If ![Pcode] <> "" Then c.HomeAddressPostalCode = ![Pcode]
         If ![Land] <> "" Then c.HomeAddressCountry = ![Land]
         If ![Telefoon] <> "" Then c.HomeTelephoneNumber = ![pf] & "/" & ![Telefoon]
         If ![fax] <> "" Then c.HomeFaxNumber = ![pf] & "/" & ![fax]
         If ![gsm] <> "" Then c.MobileTelephoneNumber = ![gsm]
         If ![E-mailadres] <> "" Then c.Email1Address = ![E-mailadres]
         '
         ' Save the contact.
         c.Save
      strMessage2 = lngCount - lngPosition & " Adressen te gaan"
      varReturn = Application.SysCmd(acSysCmdInitMeter, strMessage2, lngCount)
      varReturn = Application.SysCmd(acSysCmdUpdateMeter, lngPosition)
      .MoveNext
      Next lngPosition
      Loop
   End With
varReturn = Application.SysCmd(acSysCmdClearStatus)
   DoCmd.Hourglass False
End Sub
0
Comment
Question by:GoossensF
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9823737
Hi GoossensF,

You just avoid using .DefaultFolder().

NameSpace is a collection of all folders and property .Folders holds all. When you .use .DefaultFolder it's like asking VB to do a search within the namespace for the default folder for e.g. Contacts or Calendar.

You can check what the NameSpace 'is looking at' by:

myNameSpace.PickFolder method, - this will bring up a selection box for folder (sometimes a neat function ;-)

Use this to assign your custom folder:
   Set myFolder = myNameSpace.folders("Folder Name")

"Folder Name" can be a little tricky, if display name has been changed, it's still the original folder name that counts.


Kind regards,
Sven
0
 

Author Comment

by:GoossensF
ID: 9824158
So far I am with you but how do I adjust my code for this, I think I am in a deadlock :)
I have tried some things but it wont work
0
 
LVL 9

Accepted Solution

by:
svenkarlsen earned 200 total points
ID: 9824391
GoossensF,

Drop (or comment out) this line:
    > Set cf = olns.GetDefaultFolder(olFolderContacts)

Add this line instead/below:

    Set cf = olns.folders("Quick")

If you don't get the required result, try commenting out that line and put in this:

    set cf = olns.PickFolder

This should bring up an explorer window where you can see the available folders, - if Quick is not there, maybe it has another name in the namespace? Try guessing ?


Sven
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 9832223
Interesting app for transferring back and for th from Outlook and Access:

http://www.downlinx.com/proghtml/199/19941.htm
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 9883138
If you have not yet put this one to rest you could also check out using Outloo Redemption to write straight to your Contacts folder via code from Access.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

824 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