/build/static/layout/Breadcrumb_cap_w.png

VB script to read Current user first name, last name and contact number from outlook ?

VB script to read Current user first name, last name and contact number from outlook ?

0 Comments   [ + ] Show comments

Answers (7)

Posted by: spartacus 18 years ago
Black Belt
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
Posted by: gmorgan618 18 years ago
Blue Belt
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
Posted by: skj 18 years ago
Second Degree Brown Belt
0
Current users
Posted by: spartacus 18 years ago
Black Belt
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
Posted by: skj 18 years ago
Second Degree Brown Belt
0
Require a script which will extract Current user name (first name and last name) and contact number From the Microsoft Outlook.
Posted by: spartacus 18 years ago
Black Belt
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
Posted by: skj 18 years ago
Second Degree Brown Belt
0
Thanks a lot Spartacus for all your help....[:)]

Cheers
skj
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ