Public Sub cmdOk_Click()
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objCFolder As MAPIFolder
Dim objFolder As MAPIFolder
Dim oContact As ContactItem
Dim Mail As MailItem
Dim DistList As DistListItem
Dim DistList1 As DistListItem
Me.Hide
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objDistList = CreateObject("Redemption.SafeDistList")
Set objDistList1 = CreateObject("Redemption.SafeDistList")
Set objFolder = objNS.GetDefaultFolder(olFolderContacts)
Set objContact = CreateObject("Redemption.SafeContactItem")
Set objMail = CreateObject("Redemption.SafemailItem")
Set DistList = CreateItem(olDistributionListItem)
Set DistList1 = CreateItem(olDistributionListItem)
Set Mail = CreateItem(olMailItem)
objMail.Item = Mail
objDistList.Item = DistList
objDistList1.Item = DistList1
objContact.Item = oContact
objDistList.Item.ShowCategoriesDialog
For Each oContact In objFolder.Items
If oContact.Categories = DistList.Categories Then
If oContact.Email1Address <> "" Then
objMail.Recipients.Add (oContact.Email1Address)
End If
If oContact.Email2Address <> "" Then
objMail.Recipients.Add (oContact.Email2Address)
End If
If oContact.Email3Address <> "" Then
objMail.Recipients.Add (oContact.Email3Address)
End If
End If
DistList.AddMembers Mail.Recipients
On Error Resume Next
Next
For Each objCFolder In objFolder.Folders
For Each oContact In objCFolder.Items
If oContact.Categories = DistList.Categories Then
If oContact.Email1Address <> "" Then
Mail.Recipients.Add (oContact.Email1Address)
End If
If oContact.Email2Address <> "" Then
Mail.Recipients.Add (oContact.Email2Address)
End If
If oContact.Email3Address <> "" Then
Mail.Recipients.Add (oContact.Email3Address)
End If
End If
DistList.AddMembers Mail.Recipients
On Error Resume Next
Next
objNS.Folders.GetNext
Next
strAsk = MsgBox("Do you want to add any other types of a contact to this
list?", vbYesNo + vbInformation, "Contacts2Distribute")
If strAsk = vbYes Then
DistList1.ShowCategoriesDialog
For Each oContact In objFolder.Items
If oContact.Categories = DistList1.Categories Then
If oContact.Email1Address <> "" Then
Mail.Recipients.Add (oContact.Email1Address)
End If
If oContact.Email2Address <> "" Then
Mail.Recipients.Add (oContact.Email2Address)
End If
If oContact.Email3Address <> "" Then
Mail.Recipients.Add (oContact.Email3Address)
End If
End If
DistList.AddMembers Mail.Recipients
On Error Resume Next
Next
For Each objCFolder In objFolder.Folders
For Each oContact In objCFolder.Items
If oContact.Categories = DistList1.Categories Then
If oContact.Email1Address <> "" Then
Mail.Recipients.Add (oContact.Email1Address)
End If
If oContact.Email2Address <> "" Then
Mail.Recipients.Add (oContact.Email2Address)
End If
If oContact.Email3Address <> "" Then
Mail.Recipients.Add (oContact.Email3Address)
End If
End If
DistList.AddMembers Mail.Recipients
On Error Resume Next
Next
objNS.Folders.GetNext
Next
MsgBox "Thank you for your time.", , "Contacts4Distribution"
Else
MsgBox "Thank you for your time.", , "Contacts4Distribution"
End If
objDistList.Subject = objDistList.Categories
objDistList.Display
frmDone.Show
Set objApp = Nothing
Set objNS = Nothing
Set objCFolder = Nothing
Set objFolder = Nothing
Set Mail = Nothing
Set DistList = Nothing
Set oContact = Nothing
Set DistList1 = Nothing
End Sub
"John" - 25 Oct 2004 19:24 GMT
Hi,, 'Newbie'
I'm not at all familiar with the Redemption product. Your best bet would
be to visit their site and see if they have a community site and/or some
samples that you can check out. I would also post in the
microsoft.public.win32.programmer.messaging, since their focus is on
messaging technologies and you would have a better chance of finding
someone familiar with the tool.
Please include what error you are getting and where. I can't tell if your
code fails when you try to instantiate the Redemption object or if it is
further down. I would consider adding a reference to their DLL and trying
early binding instead.
Hope this helps,
John Eikanger
Microsoft Developer Support
This posting is provided “AS IS” with no warranties, and confers no rights.
--------------------
| From: =?Utf-8?B?dGhlTmV3Ymll?= <theNewbie@discussions.microsoft.com>
| Subject: How can I include redemption into this code?
[quoted text clipped - 118 lines]
| Set DistList1 = Nothing
| End Sub