Hi,
I got it to work with some VBScript.
You have to be logged on to Outlook to get it to work.
Now I have another problem and that is to get the script file
script.vbs in my template together with a script.js file.
I can't seem to get it in there when I allready have a js file.
If someone can help me with that I would appreciate it.
Here is my VBScript:
Sub XDocument_OnLoad(eventObj)
Dim cdoSession 'As MAPI.Session
Dim cdoAddrEntry 'As AddressEntry
Dim strData 'as string
'VBScript does not recognize constants!
' Define them explicitly or use their value.
dim CdoPR_DISPLAY_NAME
dim CdoPR_EMAIL
dim CdoPR_INITIALS
dim CdoPR_GIVEN_NAME
dim CdoPR_SURNAME
Dim vbCRLF
CdoPR_DISPLAY_NAME = &H3001001E
CdoPR_EMAIL = &H39FE001E
CdoPR_INITIALS = &H3A0A001E
CdoPR_GIVEN_NAME = &H3A06001E
CdoPR_SURNAME = &H3A11001E
vbCRLF = chr(13) & chr(10)
on error resume next
'Start the CDO code to find a match.
Set cdoSession = CreateObject("Mapi.session")
cdoSession.Logon ,,false,false,0 'Use the existing Outlook session.
if err.number <> 0 then msgbox "ERROR in logon: " & err.number & vbCRLF & err.description
'Get the AddressEntry of the recipient/current user.
Set cdoAddrEntry = cdoSession.CurrentUser
if err.number <> 0 then msgbox "ERROR getting AddressEntry: " & err.number & vbCRLF & err.description
'Get properties.
strData = "Name: " & cdoAddrEntry.fields(CdoPR_DISPLAY_NAME)
strData = strData & vbCRLF & "E-Mail: " & cdoAddrEntry.fields(CdoPR_EMAIL)
strData = strData & vbCRLF & "First name: " & cdoAddrEntry.fields(CdoPR_GIVEN_NAME)
strData = strData & vbCRLF & "Initials: " & cdoAddrEntry.fields(CdoPR_INITIALS)
strData = strData & vbCRLF & "Last name: " & cdoAddrEntry.fields(CdoPR_SURNAME)
If XDocument.DOM.selectSingleNode("//my:Status").text = "New" Then
XDocument.DOM.selectSingleNode("//my:DisplayName").text = cdoAddrEntry.fields(CdoPR_DISPLAY_NAME)
XDocument.DOM.selectSingleNode("//my:Email").text = cdoAddrEntry.fields(CdoPR_EMAIL)
XDocument.DOM.selectSingleNode("//my:Initials").text = cdoAddrEntry.fields(CdoPR_INITIALS)
XDocument.DOM.selectSingleNode("//my:GivenName").text = cdoAddrEntry.fields(CdoPR_GIVEN_NAME)
XDocument.DOM.selectSingleNode("//my:SurName").text = cdoAddrEntry.fields(CdoPR_SURNAME)
XDocument.DOM.selectSingleNode("//my:Status").text = "Old"
End If
'Explicitly release objects.
cdoSession.logoff
Set cdoAddrEntry = Nothing
Set cdoSession = Nothing
End Sub
Regards,
Hans