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
- Private Sub addNewMembers()
- Dim i As Integer
- Dim Relaties(3) As String
- Dim olApp As Outlook.Application
- Dim objItem As Outlook.DistListItem
- Dim objMail As Outlook.MailItem
- Dim objRcpnts As Outlook.Recipients
- Dim objContact As Outlook.ContactItem
- Dim objContacts As Outlook.Items
- Set olApp = New Outlook.Application
- 'vul objContacts met alle Contactpersonen en distributielijsten
- Set objContacts = olApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
- Set objMail = olApp.CreateItem(olMailItem)
- Set objRcpnts = objMail.Recipients
- 'vind distributielijst
- Set objItem = objContacts.Find("[FullName] = K_groep")
- If objItem Is Nothing Then 'als distributielijst niet bestaat
- Set objItem = olApp.CreateItem(olDistributionListItem)
- objItem.DLName = K_groep
- Else
- 'sla huidige leden op
- For i = 1 To objItem.MemberCount
- objRcpnts.Add objItem.GetMember(i).Name
- Next i
- 'verwijder hem en maak een nieuwe aan anders voert hij veranderingen niet door)
- objItem.Delete
- Set objItem = olApp.CreateItem(olDistributionListItem)
- objItem.DLName = K_groep
- End If
- Relaties(0) = K_naam
- Relaties(1) = K_naam
- Relaties(2) = K_naam
- For i = 0 To 2
- 'vind contactpersoon
- Set objContact = objContacts.Find("[Fullname] = '" & Relaties(i) & "'")
- 'als contactpersoon niet bestaat
- If objContact Is Nothing Then
- 'maak een nieuwe contact item aan
- Set objContact = objContacts.Add(olContactItem)
- objContact.FullName = Relaties(i)
- objContact.Email1Address = K_email
- objContact.Save
- End If
- Set objRcpnt = objMail.Session.CreateRecipient(objContact.Email1A ddress)
- objRcpnt.Resolve
- Set objRcpnt = objMail.Session.CreateRecipient(objContact.Email1A ddress)
- objRcpnt.Resolve
- objRcpnts.Add objContact.Email1Address 'voeg contactpersoon aan recipients toe
- Next i
- objItem.addMembers objRcpnts 'maak de contactpersonen lid van distributielijst
- objItem.Save 'sla distributielijst op
- objItem.Display 'toon distributielijst
- Set olApp = Nothing
- End Sub
I use access 2003 and outlook 2003
thx in advance