By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,240 Members | 791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,240 IT Pros & Developers. It's quick & easy.

Problem With Distributionlist in access

P: 1
made a little program in access that allows me to add members to a distribution list through access.

I only use 4 field

being 3 textbox and a command button
1 txtbox for a name
1 txtbox for the email adress
and 1 txtbox for the group name
the command button is used to add those fields into outlook.
now my problem:
I add a person, with the group name being for example "casino"
now I add a different person with the exact same group name, but it doesn't add the contactperson to the same group, it creates a different group but with the same name, and I don't want this to happen, it needs to be added to the same group name..
here's the code:

---------------------------------------------------------------------

Expand|Select|Wrap|Line Numbers
  1. Private Sub addNewMembers()
  2. Dim i As Integer
  3. Dim Relaties(3) As String
  4. Dim olApp As Outlook.Application
  5. Dim objItem As Outlook.DistListItem
  6. Dim objMail As Outlook.MailItem
  7. Dim objRcpnts As Outlook.Recipients
  8. Dim objContact As Outlook.ContactItem
  9. Dim objContacts As Outlook.Items
  10.  
  11. Set olApp = New Outlook.Application
  12. 'vul objContacts met alle Contactpersonen en distributielijsten
  13. Set objContacts = olApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
  14. Set objMail = olApp.CreateItem(olMailItem)
  15. Set objRcpnts = objMail.Recipients
  16.  
  17. 'vind distributielijst
  18. Set objItem = objContacts.Find("[FullName] = K_groep")
  19.  
  20. If objItem Is Nothing Then 'als distributielijst niet bestaat
  21. Set objItem = olApp.CreateItem(olDistributionListItem)
  22. objItem.DLName = K_groep
  23. Else
  24. 'sla huidige leden op
  25. For i = 1 To objItem.MemberCount
  26. objRcpnts.Add objItem.GetMember(i).Name
  27. Next i
  28.  
  29. 'verwijder hem en maak een nieuwe aan anders voert hij veranderingen niet door)
  30. objItem.Delete
  31. Set objItem = olApp.CreateItem(olDistributionListItem)
  32. objItem.DLName = K_groep
  33. End If
  34.  
  35. Relaties(0) = K_naam
  36. Relaties(1) = K_naam
  37. Relaties(2) = K_naam
  38.  
  39. For i = 0 To 2
  40. 'vind contactpersoon
  41. Set objContact = objContacts.Find("[Fullname] = '" & Relaties(i) & "'")
  42.  
  43. 'als contactpersoon niet bestaat
  44. If objContact Is Nothing Then
  45. 'maak een nieuwe contact item aan
  46. Set objContact = objContacts.Add(olContactItem)
  47. objContact.FullName = Relaties(i)
  48. objContact.Email1Address = K_email
  49. objContact.Save
  50. End If
  51.  
  52. Set objRcpnt = objMail.Session.CreateRecipient(objContact.Email1A ddress)
  53. objRcpnt.Resolve
  54. Set objRcpnt = objMail.Session.CreateRecipient(objContact.Email1A ddress)
  55. objRcpnt.Resolve
  56. objRcpnts.Add objContact.Email1Address 'voeg contactpersoon aan recipients toe
  57. Next i
  58.  
  59. objItem.addMembers objRcpnts 'maak de contactpersonen lid van distributielijst
  60.  
  61. objItem.Save 'sla distributielijst op
  62. objItem.Display 'toon distributielijst
  63. Set olApp = Nothing
  64.  
  65. End Sub
  66.  
-------------------------------------------------------


I use access 2003 and outlook 2003
thx in advance
Mar 28 '07 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,494
I'm sorry Titan, but although you're running this code from an Access database this is not really Access you're dealing with, it is Outlook.
There's no problem with your posting this question here of course, it's just that we are mainly Access experts so cannot really be expected to know too much about Outlook.
Maybe someone will be able to help, so leave it here, but it's less likely to find an answer than an Access question would.
Sorry.
Mar 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.