fredmartinmaine
IS-IT--Management
The script below opens the Outlook default Inbox of the logged-in user. It displays the number of emails in the inbox, then interates through the first 4 emails, displaying sender and subject.
I log in as UserOne. The script is in a shared folder. When I run the script, it works exactly as expected.
Then, I log on as UserTwo. The script fails at assigning the sender and subject variables:
Object doesn't support this property method: 'objEmailItem.SenderEmailAddress'
Same machine, same code, same Outlook install. Different users. Clearly something different in the user environment, or registry, or something similar. It's beyond me what it might be. Does objEmailItem and objOutlook come from objNameSpace? Is that's what is different between the two? Outlook was already on the machine when I logged on as each (domain) user for the first time, creating these two fresh local profiles. What could be different?
Users are the same in terms of security. Both are common domain users but in the local admin group on this machine.
I need to find out how these two users can both run this script consistently without crashing.
------------------------------
Const olFolderInbox = 6
CR = chr(13)
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)
MsgBox("Total Items: " & objFolder.Items.Count & CR & "Total Unread items: " & objFolder.UnReadItemCount)
count = 0
For Each objEmailItem In objFolder.Items
objOutlook.Quit
Set objEmailItem = Nothing
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
I log in as UserOne. The script is in a shared folder. When I run the script, it works exactly as expected.
Then, I log on as UserTwo. The script fails at assigning the sender and subject variables:
Object doesn't support this property method: 'objEmailItem.SenderEmailAddress'
Same machine, same code, same Outlook install. Different users. Clearly something different in the user environment, or registry, or something similar. It's beyond me what it might be. Does objEmailItem and objOutlook come from objNameSpace? Is that's what is different between the two? Outlook was already on the machine when I logged on as each (domain) user for the first time, creating these two fresh local profiles. What could be different?
Users are the same in terms of security. Both are common domain users but in the local admin group on this machine.
I need to find out how these two users can both run this script consistently without crashing.
------------------------------
Const olFolderInbox = 6
CR = chr(13)
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)
MsgBox("Total Items: " & objFolder.Items.Count & CR & "Total Unread items: " & objFolder.UnReadItemCount)
count = 0
For Each objEmailItem In objFolder.Items
EmailAddrStr = objEmailItem.SenderEmailAddress
EmailSenderStr = objEmailItem.Sender
EmailSubjectStr = objEmailItem.Subject
count = count + 1
MsgBox(Count & " " & EmailAddrStr & CR & EmailSenderStr & CR & EmailSubjectStr & CR)
If count = 4 Then
NextEmailSenderStr = objEmailItem.Sender
EmailSubjectStr = objEmailItem.Subject
count = count + 1
MsgBox(Count & " " & EmailAddrStr & CR & EmailSenderStr & CR & EmailSubjectStr & CR)
If count = 4 Then
Exit For
End IfobjOutlook.Quit
Set objEmailItem = Nothing
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing