473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Problem With Distributionlist in access

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
1 1925
NeoPa
32,556 Expert Mod 16PB
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

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

Similar topics

11
by: Wayne Wengert | last post by:
I am using VS.NET 2003, VB.NET, ADO.NET and an Access 2000 database. I want to display a list of all tables in an Access database. I want to put that list of table names in a listbox so the user...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
2
by: Wayne Aprato | last post by:
The following problem seems to manifest itself in Access 2000, but I have not experienced it with Access 97. When I make a duplicate of a form before I make design changes to that form that I...
3
by: Stan | last post by:
Hallo, I have developed an application in MS Access 2000 (Polish version) under MS Windows XP prof (also Polish). Now I would like to run this code on MS Windows XP EN and MS Access XP EN. I have...
4
by: Mal | last post by:
I have an ACC 2000 database that has a strange behaviour I have a small table, with just a few fields... My report has very simple grouping and sorting, no code bar a NODATA event. I have a...
3
by: dixie | last post by:
I have an Access 2000 form which has been running OK for a long time. Lately, it is playing up and doing things like causing Access to close suddenly when the form is opened or when saving the form...
1
by: Badboy36 | last post by:
Hello user from googlegroups, i made a microsoft access database with front and backend. i created the backend in microsoft access97. for the frontend i made two versions (one for microsoft...
4
by: Dave | last post by:
Hey guys, I have an ODBC problem that has me stumped. I wrote a VBA script to run in Microsoft Excel that pulls data out of an application using that application's ODBC driver and puts it into...
2
by: Joseph Geretz | last post by:
I'm having a credentialing problem in my web application. Actually, I don't think this is an IIS security issue, since I'm able to access the page I'm requesting. However, the executing page itself...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.