Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert contactitems from access to outlook

Posted on 2003-11-26
7
Medium Priority
?
552 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

705 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