Jump to content

Outlook Object


Recommended Posts

This object does not fail in Windows Vista

;//Create the Outlook Object Items
  Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError")
  Local $oNamespace = $oOutlook.GetNameSpace("MAPI")
  Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox)
  Local $oFolders = $oInbox.Parent.Folders
  ;//Count the number of Email cycles to process [One Cycle per Email]
  $Items = $oInbox.Items.Count
  ;//Initalise Processed Email Folder [sEmailSMS]
  For $oFolder In $oFolders
   If String($oFolder.Name) = $sSMSFolder Then
    $oSMSFolder = $oFolder
   EndIf
  Next

If I run the code in a Windows XP I get the following message

c:\SMS_Server\Includes\sAPIOutlook.au3 (226) : ==> Error in expression.:

Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox)

Local $oInbox = ^ ERROR

Help is always appreciated Ant..

Link to comment
Share on other sites

Is your version of Outlook on both PCs the same?

Yes I am running the same version of Outlook on both XP and Vista. This code actually works in Vista.

#include <Array.au3>
#include <GUIConstants.au3>

Const $olFolderInbox = 6
Global $oOutlook, $oSMSFolder, $oItems

$oOutlook = ObjCreate("Outlook.Application")
Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError")
Local $oNamespace = $oOutlook.GetNameSpace("MAPI")
Local $oInbox = $oNamespace.GetDefaultFolder($olFolderInbox)
Local $oFolders = $oInbox.Parent.Folders
;//Count the number of Email cycles to process [One Cycle per Email]
$Items = $oInbox.Items.Count

For $oFolder In $oFolders
If String($oFolder.Name) = $oSMSFolder Then
  $oSMSFolder = $oFolder  
EndIf
Next

$oItems = $oInbox.Items
While 1
For $oItem In $oItems
  Local $Address = $oItem.SenderEmailAddress
  MsgBox(0, "", $Address)
Next
ExitLoop
WEnd

I am not sure what the For $oFolder In $oFolders is about it looks incomplete to me. Is it a check that the inbox folder exists in which case their should be an exitloop?? Ant..

Edited by anixon
Link to comment
Share on other sites

Did you have a look at the Outlook UDF? Maybe the function you need is already included. Our you might get a hint from the source code.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks to all subscribers for assistance. As it turned out my issue was I had not applied a global setting to one of the variables which would bring me to the conclusion that it was not XP Vista OS related I have been running the routine in a loop now for nearly 24 hours without it failing so I am happy that the code does what it is designed to do. Thanks for pointing me to the Wooltown Outlook UDF which I had forgotten about. For those building Outlook related scripts an excellent resource when constructing object orientated outlook routines. Ant..

Edited by anixon
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...