/bundles/itninjaweb/img/Breadcrumb_cap_w.png
VB script to read Current user first name, last name and contact number from outlook ?
0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

0
I assume you mean you wish to read this from the contacts list .... ?

If so, the following should help get you started - it's an extract from a Technet article, so I can't claim any credit, myself [;)]


[font="Courier New"]On Error Resume Next

Const olFolderContacts = 10

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set colContacts = objNamespace.GetDefaultFolder(olFolderContacts).Items

For Each objContact In colContacts
Wscript.Echo objContact.FullName, objContact.BusinessTelephoneNumber
Next

Regards,

Spartacus
Answered 07/14/2006 by: spartacus
Black Belt

Please log in to comment
0
if you need the first and last name seperated...

arrName = Split(objContact.FullName, " ") 'Change the " " to the actual delimiter which might be ", "(comma space) - I'm not sure how names are extracted --> this will return an array split by the delimiter so ...
strFirstName = arrName(0)
strLastName = arrName(1)

Hopefully you get the idea. if the user had a first middel and last name like Joe williams bob then
strFirstName = arrName(0)
strMiddleName = arrName(1)
strLastName = arrName(2)

Good Luck
Answered 07/14/2006 by: gmorgan618
Blue Belt

Please log in to comment
0
Current users
Answered 07/17/2006 by: skj
Second Degree Brown Belt

Please log in to comment
0
In which case, you may need to do some searching around in MSDN / Google, using the following as a search string :

Application.GetNameSpace("MAPI").CurrentUser

in order to obtain some sample code.


Regards,

Spartacus
Answered 07/18/2006 by: spartacus
Black Belt

Please log in to comment
0
Require a script which will extract Current user name (first name and last name) and contact number From the Microsoft Outlook.
Answered 07/19/2006 by: skj
Second Degree Brown Belt

Please log in to comment
0
OK, try this out - note that you may get security related popups using this if the Outlook Security patches have been applied - I don't know of an easy way to override them, or even if one exists ...

Const PR_GIVEN_NAME = &H3a06001e
Const PR_INITIALS = &H3a0a001e
Const PR_SURNAME = &H3a11001e
Const PR_7BIT_DISPLAY_NAME = &H39ff001e
Const PR_STREET_ADDRESS = &H3a29001e
Const PR_LOCALITY = &H3a27001e
Const PR_STATE_OR_PROVINCE = &H3a28001e
Const PR_POSTAL_CODE = &H3a2a001e
Const PR_COUNTRY = &H3a26001e
Const PR_TITLE = &H3a17001e
Const PR_COMPANY_NAME = &H3a16001e
Const PR_DEPARTMENT_NAME = &H3a18001e
Const PR_OFFICE_LOCATION = &H3a19001e
Const PR_ASSISTANT = &H3a30001e
Const PR_BUSINESS_TELEPHONE_NUMBER = &H3a08001e


set Application = GetObject("","Outlook.application")
' If there was an error, Outlook probably wasn't Open, so open it now
if err.number <> 0 then
err.clear
set Application = CreateObject("Outlook.application")
if err.number <> 0 then
msgbox "Problem trying to create Outlook object, unable to continue"
wscript.quit
end if
end if

set olemSession = Application.CreateObject("MAPI.Session")
ReturnStatus = olemSession.Logon( Application.GetNameSpace("MAPI").CurrentUser, "", False, False, 0 )

Set myself = olemSession.CurrentUser

msgbox myself.Fields.Item(PR_GIVEN_NAME) & " " & myself.Fields.Item(PR_SURNAME) & " " & myself.Fields.Item(PR_BUSINESS_TELEPHONE_NUMBER)


Just as an aside, the moderator(s) may wish to move this to the scripting forum as I haven't seen anything packaging related in this thread (yet) [:)]

Regards,

Spartacus
Answered 07/19/2006 by: spartacus
Black Belt

Please log in to comment
0
Thanks a lot Spartacus for all your help....[:)]

Cheers
skj
Answered 07/19/2006 by: skj
Second Degree Brown Belt

Please log in to comment