Jump to content
Sign in to follow this  
anixon

Outlook Object

Recommended Posts

anixon

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..

Share this post


Link to post
Share on other sites
anixon

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

Share this post


Link to post
Share on other sites
Juvigy

The above code works for me. XP / outlook 2007

What error exactly do you get?

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
anixon

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

Share this post


Link to post
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
Sign in to follow this  

×