Get start with Outlook from Access 2000?

M

MusMou

I would like to get a very simple example witch loops through the contacts
folder and debugs the result and also how to create contacts change them and
delete them I´m using Microsoft Outlook 10.0 Object Library
So please help me get started
thank you
Mustapha
 
D

Dave Patrick

I would start by asking them here. Once you have it working within Outlook
it should be fairly easy to port it over to work in Access.

http://www.microsoft.com/communitie...ded-ffa8-474e-a28d-ef611f1d45b4&lang=en&cr=US

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I would like to get a very simple example witch loops through the contacts
| folder and debugs the result and also how to create contacts change them
and
| delete them I´m using Microsoft Outlook 10.0 Object Library
| So please help me get started
| thank you
| Mustapha
 
S

Sandro

MusMou said:
I would like to get a very simple example witch loops through the contacts
folder and debugs the result and also how to create contacts change them and
delete them I´m using Microsoft Outlook 10.0 Object Library
So please help me get started
thank you
Mustapha

HI Mustapha,

in this italian web site you can find one of my demo : with that you can
import, export, delete from Access your Outlook contacts.

6.196 Esportare, importare o cancellare i contatti di Outlook da VBA
general section

Here is the Url : www.sitocomune.it.

HTH, Ciao, Sandro.
 
D

David C. Holley

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
'Set targetItems = targetFolder.Items.Restrict(strFilter)

Set targetItems = targetFolder.Items

For Each targetContact In targetItems
With targetContact
Debug.Print .NickName, .FirstName, .LastName, .CompanyName
End With
Next

Set targetContact = Nothing
Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub
 
D

David C. Holley

To change the item simply put the statements in the With targetContact
loop as in

with targetContact
.CompanyName = "Microsoft World Domination, LLC"
end with

BUT, if you're deleting the contact, that has to be done outside of a
loop. VBA gets wacked out if your looping through items in a collection
and deleting them. For that, use the .Restrict method to grab the
specific contact and then execute .Delete. The two lines to use the
..Restrict method are commented out in the code I just posted.
 
D

Dave Patrick

For this try reading them all into an array then read back the array to
delete the items.

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
<snip>
VBA gets wacked out if your looping through items in a collection
| and deleting them.
<snip>
 
M

MusMou

Hi David,
The code you sent me works but to use the commented lines with the statment
Restrict, how can I debug the item I´m searching and even how would the
delete statment look like?
Best Reguards
Mustapha

"David C. Holley" skrev:
Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
'Set targetItems = targetFolder.Items.Restrict(strFilter)

Set targetItems = targetFolder.Items

For Each targetContact In targetItems
With targetContact
Debug.Print .NickName, .FirstName, .LastName, .CompanyName
End With
Next

Set targetContact = Nothing
Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub

I would like to get a very simple example witch loops through the contacts
folder and debugs the result and also how to create contacts change them and
delete them I´m using Microsoft Outlook 10.0 Object Library
So please help me get started
thank you
Mustapha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top