Link to home
Start Free TrialLog in
Avatar of cantrell
cantrell

asked on

MAPI question

I am showing the 'address book' using the mapisession control, and that works fine - I just need to know how to get the email address of the person they select. How do I do that?
Avatar of TT
TT

Private Sub GetAddress()

Dim lsTo as String
Dim lsCc as String
Dim MAPIMess as MAPIMessages
   :
   :
' Show MAPI Address book & did selection  
   :
   :
lsTo = GetRCList(MAPIMess,  
vbRecipTypeTo)

lsCc = GetRCList(MAPIMess,  
vbRecipTypeCc)

End Sub
Function GetRCList(ByRef Msg As Control, _
ByVal RCType As Integer _
) As String

Dim liloopi_cnt As Integer
Dim lsTmp_str As String
       
For liloopi_cnt = 0 ToMsg.RecipCount - 1
    Msg.RecipIndex = liloopi_cnt
    If RCType = Msg.RecipType Then
       lsTmp_str = lsTmp_str + ";" +
       Msg.RecipDisplayName
    End If
Next liloopi_cnt

If lsTmp_str <> "" Then
   lsTmp_str = Mid(lsTmp_str, 2)  
   'Strip off the leading ";".
End If

GetRCList = lsTmp_str

End Function
Avatar of cantrell

ASKER

I get an error message "Object Variable or With Variable Not set" when I use this code... Any ideas?
Hi, I am expected u are already login to
MAPI Sessions and manage to get into
addresses selection screen, did u ?

if yes, of course u shd replace the
MAPIMessages that I had named MAPIMESS
to what u name it.
ASKER CERTIFIED SOLUTION
Avatar of TT
TT

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I got it working. Thank you for your help.