NEWBIE: to delete distrbution list from contact list 
Author Message
 NEWBIE: to delete distrbution list from contact list

I am having trouble with this  please help. it update via Access DB

here is the code

sub Item_Open()

item.body = "This form will update your Contacts list in your personnal
address Book "
item.Subject = " Updates for Personnal address Book "
end sub

Sub Comadd_Click()

dim oDatabase, rst

Set objAcc1 = CreateObject("Access.Application")
 set objApp = CreateObject("Outlook.Application")

 Set objDBE1 = objAcc1.DBEngine
 Set dbs = objDBE1.OpenDatabase("p:\update.mdb")
 Set objns = objApp.GetNamespace("MAPI")

 Set cf = objns.GetDefaultFolder(10)
 'Set myitems = cf.items
Set itms = cf.Items

'#############################################
'   Delete Section
'#############################################

squery = "select * from contact where action = 'delete'"
 Set rst = dbs.OpenRecordset(squery)

  Do Until rst.EOF

  Set itm = itms.delete("IPM.Contact.Access Contact")

 itm.CustomerName = rst.CustomerName

    itm.Close(0)

  rst.MoveNext

 Loop

First place it hangs up is the  "    itms.delete(IPM   "  line



Thu, 01 Jul 2004 02:18:11 GMT  
 NEWBIE: to delete distrbution list from contact list
Wrong syntax. Delete is a method of individual Outlook items, not the Items collection. First you need to get the item you want to delete, then you use the Delete method on that specific item:

itm.Delete

I can't tell from your code whether you're trying to delete only specific items. If so, you can use Items.Find with a search string to locate each item that you want to delete in succession.

Also, I don't see how this code relates to the distribution list in the subject of your post.

--
Sue Mosher, Outlook MVP
   Outlook and Exchange Solutions
   at http://www.slipstick.com

Quote:

> I am having trouble with this  please help. it update via Access DB

> here is the code

> sub Item_Open()

> item.body = "This form will update your Contacts list in your personnal
> address Book "
> item.Subject = " Updates for Personnal address Book "
> end sub

> Sub Comadd_Click()

> dim oDatabase, rst

> Set objAcc1 = CreateObject("Access.Application")
>  set objApp = CreateObject("Outlook.Application")

>  Set objDBE1 = objAcc1.DBEngine
>  Set dbs = objDBE1.OpenDatabase("p:\update.mdb")
>  Set objns = objApp.GetNamespace("MAPI")

>  Set cf = objns.GetDefaultFolder(10)
>  'Set myitems = cf.items
> Set itms = cf.Items

> '#############################################
> '   Delete Section
> '#############################################

> squery = "select * from contact where action = 'delete'"
>  Set rst = dbs.OpenRecordset(squery)

>   Do Until rst.EOF

>   Set itm = itms.delete("IPM.Contact.Access Contact")

>  itm.CustomerName = rst.CustomerName

>     itm.Close(0)

>   rst.MoveNext

>  Loop

> First place it hangs up is the  "    itms.delete(IPM   "  line



Thu, 01 Jul 2004 03:47:48 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Deleting Contacts and Dist Lists in same folder

2. Add Contacts to a PublicFolder Contact list

3. VBA Display selected contacts/people from a Shared contact list

4. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

5. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

6. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

7. Outlook 2002 Contact List/Address Book

8. importing excel list into outlook contacts

9. Outlook Contact list

10. sending personalized message to all in contact list

11. Running through a list of contacts

12. How make list of the other folder contact ?

 

 
Powered by phpBB® Forum Software