Hi
I have some code which connect to the current outlook session and then displays the email selection list from out on screen. When ok is selected a text box is populated with the names selected:
Public Function AmmendEmailList(MyArray As XArray) As Boolean
Dim r As Integer
Dim doo As Integer
Dim MyErrNumber As Long
Dim MyErrDescription As String
Dim NewRec As Integer
Dim FullToText As String
doo = 0
AmmendEmailList = True
On Error GoTo err1:
Screen.MousePointer = 11
'sign on to email
MDISpecMain.MAPISession1.LogonUI = True
MDISpecMain.MAPISession1.SignOn
MDISpecMain.MAPIMessages1.SessionID = MDISpecMain.MAPISession1.SessionID
'open temp message
MDISpecMain.MAPIMessages1.MsgIndex = -1
'remove any email receps
For r = MDISpecMain.MAPIMessages1.RecipCount To 0 Step -1
MDISpecMain.MAPIMessages1.RecipIndex = r
MDISpecMain.MAPIMessages1.Delete mapRecipientDelete
Next r
NewRec = 0
'fill Recip list with known names
MDISpecMain.MAPIMessages1.AddressResolveUI = True
For r = 0 To MyArray.UpperBound(1)
MDISpecMain.MAPIMessages1.RecipIndex = NewRec
MDISpecMain.MAPIMessages1.RecipDisplayName = MyArray(r, 0)
MDISpecMain.MAPIMessages1.ResolveName
If doo = 1 Then
If Trim$(MyArray(r, 0)) <> "" Then
MsgBox "Invalid Email Address '" & Trim$(MyArray(r, 0)) & "'", vbCritical + vbOKOnly, "User not found"
End If
MDISpecMain.MAPIMessages1.Delete mapRecipientDelete
doo = 0
Else
NewRec = NewRec + 1
End If
Next r
Screen.MousePointer = 0
'show and edit resolved names
MDISpecMain.MAPIMessages1.Show False
'put Recip list back into MyArray
MyArray.ReDim 0, -1, 0, -1
MyArray.ReDim 0, MDISpecMain.MAPIMessages1.RecipCount - 1, 0, 1
For r = MDISpecMain.MAPIMessages1.RecipCount - 1 To 0 Step -1
MDISpecMain.MAPIMessages1.RecipIndex = r
MyArray(r, 0) = MDISpecMain.MAPIMessages1.RecipDisplayName
MDISpecMain.MAPIMessages1.Delete mapRecipientDelete
Next r
On Error GoTo 0
Exit Function
err1:
MyErrNumber = Err.Number
MyErrDescription = Err.Description
If MyErrNumber = 32050 Then ' All ready logged on
Resume Next
ElseIf MyErrNumber = 32003 Then
MDISpecMain.MAPISession1.LogonUI = True
Resume
ElseIf MyErrNumber = 32001 Then
AmmendEmailList = False
Resume SkipSave:
ElseIf MyErrNumber = 32014 Or MyErrNumber = 32021 Or MyErrNumber = 32011 Then
MsgBox "Can not find Email Address for '" & MyArray(r, 0) & "'", vbExclamation + vbOKOnly, "User not found"
Resume Next
Else
doo = 1
Resume Next
End If
End Function
This line shows the conatcs
MDISpecMain.MAPIMessages1.Show False
no matter how many contacts i select MDISpecMain.MAPIMessages1.RecipCount is always = 0
this only happen on windows 7.
On windows XP its fine.
We are using outlook 2003 and 2007 and is the same for both
Thanks
I have some code which connect to the current outlook session and then displays the email selection list from out on screen. When ok is selected a text box is populated with the names selected:
Public Function AmmendEmailList(MyArray As XArray) As Boolean
Dim r As Integer
Dim doo As Integer
Dim MyErrNumber As Long
Dim MyErrDescription As String
Dim NewRec As Integer
Dim FullToText As String
doo = 0
AmmendEmailList = True
On Error GoTo err1:
Screen.MousePointer = 11
'sign on to email
MDISpecMain.MAPISession1.LogonUI = True
MDISpecMain.MAPISession1.SignOn
MDISpecMain.MAPIMessages1.SessionID = MDISpecMain.MAPISession1.SessionID
'open temp message
MDISpecMain.MAPIMessages1.MsgIndex = -1
'remove any email receps
For r = MDISpecMain.MAPIMessages1.RecipCount To 0 Step -1
MDISpecMain.MAPIMessages1.RecipIndex = r
MDISpecMain.MAPIMessages1.Delete mapRecipientDelete
Next r
NewRec = 0
'fill Recip list with known names
MDISpecMain.MAPIMessages1.AddressResolveUI = True
For r = 0 To MyArray.UpperBound(1)
MDISpecMain.MAPIMessages1.RecipIndex = NewRec
MDISpecMain.MAPIMessages1.RecipDisplayName = MyArray(r, 0)
MDISpecMain.MAPIMessages1.ResolveName
If doo = 1 Then
If Trim$(MyArray(r, 0)) <> "" Then
MsgBox "Invalid Email Address '" & Trim$(MyArray(r, 0)) & "'", vbCritical + vbOKOnly, "User not found"
End If
MDISpecMain.MAPIMessages1.Delete mapRecipientDelete
doo = 0
Else
NewRec = NewRec + 1
End If
Next r
Screen.MousePointer = 0
'show and edit resolved names
MDISpecMain.MAPIMessages1.Show False
'put Recip list back into MyArray
MyArray.ReDim 0, -1, 0, -1
MyArray.ReDim 0, MDISpecMain.MAPIMessages1.RecipCount - 1, 0, 1
For r = MDISpecMain.MAPIMessages1.RecipCount - 1 To 0 Step -1
MDISpecMain.MAPIMessages1.RecipIndex = r
MyArray(r, 0) = MDISpecMain.MAPIMessages1.RecipDisplayName
MDISpecMain.MAPIMessages1.Delete mapRecipientDelete
Next r
On Error GoTo 0
Exit Function
err1:
MyErrNumber = Err.Number
MyErrDescription = Err.Description
If MyErrNumber = 32050 Then ' All ready logged on
Resume Next
ElseIf MyErrNumber = 32003 Then
MDISpecMain.MAPISession1.LogonUI = True
Resume
ElseIf MyErrNumber = 32001 Then
AmmendEmailList = False
Resume SkipSave:
ElseIf MyErrNumber = 32014 Or MyErrNumber = 32021 Or MyErrNumber = 32011 Then
MsgBox "Can not find Email Address for '" & MyArray(r, 0) & "'", vbExclamation + vbOKOnly, "User not found"
Resume Next
Else
doo = 1
Resume Next
End If
End Function
This line shows the conatcs
MDISpecMain.MAPIMessages1.Show False
no matter how many contacts i select MDISpecMain.MAPIMessages1.RecipCount is always = 0
this only happen on windows 7.
On windows XP its fine.
We are using outlook 2003 and 2007 and is the same for both
Thanks