skj
Posts: 40
Joined: Thu Apr 07, 2005 11:08 am

VB script 2Read Current User first, last name&contactNo

VB script to read Current user first name, last name & contact number from outlook ?
Last edited by skj on Tue Jul 18, 2006 10:32 am, edited 3 times in total.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

I don't really understand what you are trying to achieve. Please give me more details.

Regards,
Gigi
_________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
skj
Posts: 40
Joined: Thu Apr 07, 2005 11:08 am

There is registration to be done, we require user first name and last name
from the name we get the email id and the contact no is used for calling
davincicode
Posts: 7
Joined: Wed Apr 13, 2005 1:49 pm

skj wrote:There is registration to be done, we require user first name and last name
from the name we get the email id and the contact no is used for calling
Google is a good tool for finding code examples. There's a lot of VBS out there, including this from Microsoft which is a good start:

http://support.microsoft.com/?kbid=263572
skj
Posts: 40
Joined: Thu Apr 07, 2005 11:08 am

Require a script which will extract Current user name (first name and last name) and contact number From the Microsoft Outlook.
skj
Posts: 40
Joined: Thu Apr 07, 2005 11:08 am

Got the Script ;)

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)

Return to “Common Problems”