I am calling a VBS function from an intranet page, using IE 11 (yes, it has to be that browser). The function processes an Outlook mailbox, and is partly working: I can run down the list of mails and find the Subject and Body, but I need the sender's email address. I can get this in various ways when I run similar code as an Outlook macro, but none of them work in VBS - the script just hangs (no error message) when I try to get anything of interest - see the function, with various things I've tried commented. Any pointers as to where I'm going wrong gratefully received....
Function readEmails(mailbox)
Dim iCt
Set objOutlook = CreateObject("Outlook.Application")
Set NS = objOutlook.GetNamespace("MAPI")
Set olFolder = NS.Folders(mailbox)
Set olFolInbox = olFolder.Folders("Inbox")
iCt = 0
For iCt =1 to olFolInbox.Items.Count
set olMessage=olFolInbox.Items(iCt)
msgbox(ict & "-" & olMessage.Subject )
msgbox("SenderEmailType=" & olMessage.SenderEmailType)
msgbox("SenderEmailAddress=" & olMessage.SenderEmailAddress) 'hangs
'set sn=olMessage.SenderName 'hangs
set sUser=olMessage.Sender
'set sn=sUser.Name 'hangs
'msgbox(sUser) 'hangs
'set sExUser=sUser.GetExchangeUser ' hangs
End If
Next
readEmails=sReturn
End Function