Error in vbscript code trying to return FormatDateTime(myTime.ReceivedTime

G

GlenD

I get a vbscript error at the point indicated in the code below and can
not seem to figure out what the correction should be. Vbscript
debugger only indicates an error at this line number nothing more.

Thanks
Glen


Function Item_Open()
' PublishAsForm
Dim oMapi
Dim oFolder
Dim oApp
Dim myItem
Dim myDate
Set oApp = CreateObject("Outlook.Application")
Set oMapi = Application.GetNamespace("MAPI")
Set oFolder = oApp.ActiveExplorer.CurrentFolder
Item.UserProperties.Find("ItemsInInbox") = oFolder.Items.Count
Item.UserProperties.Find("FoldersInInbox") = oFolder.Folders.Count
Item.UserProperties.Find("UnReadItemInInbox")= oFolder.UnReadItemCount
Set myItem = oFolder.Items(2)
-----> error here myDate = FormatDateTime(myItem.ReceivedTime,2)
Item.UserProperties.Find("InboxOldestUnReadItem") = myDate

MsgBox " Current folder is - " & oFolder.Name & ". It has " &
CStr(oFolder.Folders.Count) & " folders in it"
MsgBox " and " & oFolder.Name & " has " & CStr(oFolder.Items.Count)
& " in it."
MsgBox " of which " & CStr(oFolder.UnReadItemCount) & " items are
unread" & " and item(1) has a recieved time of " & myDate

mIsLoaded = -1
End Function
 
G

GlenD

In an effort to further debug this problem I havbe turned to the use of
the EntryID property to get the associated CDO item a selected
mailitem. However now any mention of the EntryID or StoreID in my
vbscript code causes an VBscript error on the line the property is
mentioned.

I am truly stopped - and do not know which way to turn can any one
suggest a direction forward.

Sample vbs code below taken from Sue M.'s book

Function GetCDOItemFromOL( objOLItem )
Dim objApp
Dim strEntryID
Dim strStoreID
Set objApp = CreateObject("Outlook.Application")
MsgBox "Item type is " & TypeName(objOLItem) ---- debug info
MsgBox "Subject Item for current retrieved message is " &
objOLItem.Subject
MsgBox " With EntryID = " & objOLItem.EntryID ----- Error occurs on
this line
strStoreId = objOLItem.Parent.StoreID
strEntryId = objOLItem.EntryID

If g_CDOSession is Nothing Then
Call DoCDOLogon
End If
Set GetCDOItemFromOL = g_CDOSession.GetMessage(strEntryId, strStoreId)
Set objApp = Nothing
End Function




Thanks
Glen Duval
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top