![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|