A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

CDO Active Directory and Mail Enabling



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 9th 06, 05:01 PM posted to microsoft.public.outlook
[email protected]
external usenet poster
 
Posts: 1
Default CDO Active Directory and Mail Enabling

Can anybody explain why we'd receive a "type mismatch" error in a mail
enable routine with CDO, LDAP and Outlook 2003? Here's some sample
code with the line that fails in bold. The catch is that it works on
some systems, but not others, so I think it may be a dependency issue.
I've added a comment indicating which line generates the type mismatch
error. The code was pulled from Microsoft's Knowledge Base.

Creating a Distribution List Using CDOEXM and ADSI

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

Visual Basic
' Creating a Distribution List Using CDOEXM and ADSI
' This sample creates a distribution list in a given Active Directory
container. It uses a slightly
' modified version of the Microsoft Platform SDK code to create a
group, and then
' mail-enables the group using CDOEXM.

' A distribution list in Exchange 2000 is a normal Windows 2000 group,
either security
' or non-security, which has been mail-enabled. This sample uses the
function
' CreateDL to create the distribution list and CDOEXM to mail-enable
it.

Function CreateDL(strPath As String, strGroupName As String,
strSamAcctName As String, strGroupType As String, bSecurity As Boolean)
As IADsGroup
' ================================================== =======
' CreateDL(strPath As String, strGroupName As String, strSamAcctName As
String,
' strGroupType As String, bSecurity As Boolean)
' strPath = ADsPath of the container under which the group will be
created
' strGroupName = Name of the group to be created
' strSamAcctName = Group name as it will appear to pre-Windows 2000
computers
' strGroupType = Type of group to be created (Local, Domain Local,
Global, or Universal)
' bSecurity = Is this a security group?

' Function returns an IADsGroup object.

' Example of calling the function:
' Set objNewGroup = CreateDL("LDAP://cn=Users,dc=corp,dc=com", "My New
Group", "NewGroup", "Global", False)
' Then add users
' objNewGroup.Add strUser1ADsPath
' objNewGroup.Add strUser2ADsPath
' ================================================== =======

Dim lGroupType As Long
Dim iAdCont As IADsContainer
Dim iAdGroup As IADsGroup
Dim iMailRecip As IMailRecipient

' --- Set the Type of Group ------
lGroupType = 0
Select Case UCase(strGroupType)
Case "LOCAL": lGroupType = ADS_GROUP_TYPE_LOCAL_GROUP
Case "DOMAIN LOCAL": lGroupType = ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP
Case "GLOBAL": lGroupType = ADS_GROUP_TYPE_GLOBAL_GROUP
Case "UNIVERSAL": lGroupType = ADS_GROUP_TYPE_UNIVERSAL_GROUP
Case Else
Debug.Print "This is not a proper group type"
Exit Function
End Select


' ---- Check to See if it is a Security Group ----
If bSecurity Then
lGroupType = lGroupType Or ADS_GROUP_TYPE_SECURITY_ENABLED
End If

' ---- Create the Group ----
Set iAdCont = GetObject(strPath)
Set iAdGroup = iAdCont.Create("group", "cn=" + strGroupName)
iAdGroup.Put "sAMAccountName", strSamAcctName
iAdGroup.Put "groupType", lGroupType

' Flush to the directory
iAdGroup.SetInfo

'--- Mail Enable ----
Set iMailRecip = iAdGroup ----- THIS IS THE LINE THAT GENERATES THE
MISMATCH
iMailRecip.MailEnable

' Write Exchange information to the directory.
iAdGroup.SetInfo

' Return the group.
Set CreateDL = iAdGroup

' Clean up.
Set iMailRecip = Nothing
Set iAdGroup = Nothing
Set iAdCont = Nothing
End Function

Ads
  #2  
Old January 10th 06, 02:57 PM posted to microsoft.public.outlook
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default CDO Active Directory and Mail Enabling

This should be posted to an Exchange development group, not an Outlook
general purpose group.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


wrote in message
ups.com...
Can anybody explain why we'd receive a "type mismatch" error in a mail
enable routine with CDO, LDAP and Outlook 2003? Here's some sample
code with the line that fails in bold. The catch is that it works on
some systems, but not others, so I think it may be a dependency issue.
I've added a comment indicating which line generates the type mismatch
error. The code was pulled from Microsoft's Knowledge Base.

Creating a Distribution List Using CDOEXM and ADSI

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

Visual Basic
' Creating a Distribution List Using CDOEXM and ADSI
' This sample creates a distribution list in a given Active Directory
container. It uses a slightly
' modified version of the Microsoft Platform SDK code to create a
group, and then
' mail-enables the group using CDOEXM.

' A distribution list in Exchange 2000 is a normal Windows 2000 group,
either security
' or non-security, which has been mail-enabled. This sample uses the
function
' CreateDL to create the distribution list and CDOEXM to mail-enable
it.

Function CreateDL(strPath As String, strGroupName As String,
strSamAcctName As String, strGroupType As String, bSecurity As Boolean)
As IADsGroup
' ================================================== =======
' CreateDL(strPath As String, strGroupName As String, strSamAcctName As
String,
' strGroupType As String, bSecurity As Boolean)
' strPath = ADsPath of the container under which the group will be
created
' strGroupName = Name of the group to be created
' strSamAcctName = Group name as it will appear to pre-Windows 2000
computers
' strGroupType = Type of group to be created (Local, Domain Local,
Global, or Universal)
' bSecurity = Is this a security group?

' Function returns an IADsGroup object.

' Example of calling the function:
' Set objNewGroup = CreateDL("LDAP://cn=Users,dc=corp,dc=com", "My New
Group", "NewGroup", "Global", False)
' Then add users
' objNewGroup.Add strUser1ADsPath
' objNewGroup.Add strUser2ADsPath
' ================================================== =======

Dim lGroupType As Long
Dim iAdCont As IADsContainer
Dim iAdGroup As IADsGroup
Dim iMailRecip As IMailRecipient

' --- Set the Type of Group ------
lGroupType = 0
Select Case UCase(strGroupType)
Case "LOCAL": lGroupType = ADS_GROUP_TYPE_LOCAL_GROUP
Case "DOMAIN LOCAL": lGroupType = ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP
Case "GLOBAL": lGroupType = ADS_GROUP_TYPE_GLOBAL_GROUP
Case "UNIVERSAL": lGroupType = ADS_GROUP_TYPE_UNIVERSAL_GROUP
Case Else
Debug.Print "This is not a proper group type"
Exit Function
End Select


' ---- Check to See if it is a Security Group ----
If bSecurity Then
lGroupType = lGroupType Or ADS_GROUP_TYPE_SECURITY_ENABLED
End If

' ---- Create the Group ----
Set iAdCont = GetObject(strPath)
Set iAdGroup = iAdCont.Create("group", "cn=" + strGroupName)
iAdGroup.Put "sAMAccountName", strSamAcctName
iAdGroup.Put "groupType", lGroupType

' Flush to the directory
iAdGroup.SetInfo

'--- Mail Enable ----
Set iMailRecip = iAdGroup ----- THIS IS THE LINE THAT GENERATES THE
MISMATCH
iMailRecip.MailEnable

' Write Exchange information to the directory.
iAdGroup.SetInfo

' Return the group.
Set CreateDL = iAdGroup

' Clean up.
Set iMailRecip = Nothing
Set iAdGroup = Nothing
Set iAdCont = Nothing
End Function


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.