MattSmithProg
Programmer
Hi,
I have a little problem trying to resolve an email address via the alias.
Normally I have this code to resolve an email address and return the display name and office.
Function GetNameAndSiteFromOutlook(sUserId) As Boolean
'sUserId is passed via an input form where the user enters a UserId of a person and then it attempts to return the display name and Office of the person
Dim objSession As MAPI.Session
Dim objMessage As MAPI.Message
Dim objonerecip As MAPI.Recipient
Dim myaddentry As MAPI.AddressEntry
Dim myFields As MAPI.Fields
Dim myoffice As MAPI.Field
'Gets UserId of system machine for logon to Outlook
Call Declaration.GetUserId
Set objSession = CreateObject("MAPI.Session"
objSession.Logon strUserId, , False, False
Set objMessage = objSession.Outbox.Messages.Add
Set objonerecip = objMessage.Recipients.Add (Name:=sUserId, Type:=CdoTo)
objonerecip = sUserId
'Seeing if a user exists.
On Error GoTo X
objonerecip.Resolve (False)
On Error GoTo Proc_Err
'Getting office details
Set myaddentry = objonerecip.AddressEntry
Set myFields = myaddentry.Fields
Set myoffice = myFields.Item(&H3A19001E)
strUserName = myaddentry.Name
strSite = myoffice.Value
Set objSession = Nothing
Set objMessage = Nothing
Exit Function
PROC_ERR:
objSession.Logon , , True, False
Resume Next
X:
GetNameAndSiteFromOutlook = True
Exit Function
End Function
I have now come along a problem where a person's surname is exactly the same as the alias. This is causing the resolve not to work as there are two people that the alias could be.
What I want to do is pass the UserId of the person directly to CDO so it won't look at the display name at all and therefore not have any resolving conflict.
I hope I am making sense. If anyone could help me I would be greatly appreciative.
Thanks
Matt Smith
No two nulls are the same
I have a little problem trying to resolve an email address via the alias.
Normally I have this code to resolve an email address and return the display name and office.
Function GetNameAndSiteFromOutlook(sUserId) As Boolean
'sUserId is passed via an input form where the user enters a UserId of a person and then it attempts to return the display name and Office of the person
Dim objSession As MAPI.Session
Dim objMessage As MAPI.Message
Dim objonerecip As MAPI.Recipient
Dim myaddentry As MAPI.AddressEntry
Dim myFields As MAPI.Fields
Dim myoffice As MAPI.Field
'Gets UserId of system machine for logon to Outlook
Call Declaration.GetUserId
Set objSession = CreateObject("MAPI.Session"
objSession.Logon strUserId, , False, False
Set objMessage = objSession.Outbox.Messages.Add
Set objonerecip = objMessage.Recipients.Add (Name:=sUserId, Type:=CdoTo)
objonerecip = sUserId
'Seeing if a user exists.
On Error GoTo X
objonerecip.Resolve (False)
On Error GoTo Proc_Err
'Getting office details
Set myaddentry = objonerecip.AddressEntry
Set myFields = myaddentry.Fields
Set myoffice = myFields.Item(&H3A19001E)
strUserName = myaddentry.Name
strSite = myoffice.Value
Set objSession = Nothing
Set objMessage = Nothing
Exit Function
PROC_ERR:
objSession.Logon , , True, False
Resume Next
X:
GetNameAndSiteFromOutlook = True
Exit Function
End Function
I have now come along a problem where a person's surname is exactly the same as the alias. This is causing the resolve not to work as there are two people that the alias could be.
What I want to do is pass the UserId of the person directly to CDO so it won't look at the display name at all and therefore not have any resolving conflict.
I hope I am making sense. If anyone could help me I would be greatly appreciative.
Thanks
Matt Smith
No two nulls are the same