Jump to content

object has failed?


Recommended Posts

Just trying something out with Outlook. Goes through my Inbox gets all messages that contain attachments then its SUPPOSED to save them to a folder. However when i get to one method, SaveAsFile, it gives me this error:

The requested action with this object has failed.:

$attachment.SaveAsFile $filename

$attachment.SaveAsFile ^ ERROR

Dim $objOutlook, $objNameSpace, $objFolder, $MyItems
Dim $objMessage, $attachment, $filename

$objOutlook = ObjCreate("Outlook.application")
$objNameSpace = $objOutlook.GetNameSpace("MAPI")
$objFolder = $objNameSpace.GetDefaultFolder(6)
$MyItems = $objFolder.Items

For $objMessage In $MyItems
    For $attachment In $objMessage.Attachments
        $filename = "c:\" & $attachment.filename
        $attachment.SaveAsFile $filename
    Next
Next

Thanks for any help or pointers

Link to comment
Share on other sites

Just trying something out with Outlook. Goes through my Inbox gets all messages that contain attachments then its SUPPOSED to save them to a folder. However when i get to one method, SaveAsFile, it gives me this error:

The requested action with this object has failed.:

$attachment.SaveAsFile $filename

$attachment.SaveAsFile ^ ERROR

Thanks for any help or pointers

Put Parentheses around the filename as in

CODE
$attachment.SaveAsFile($filename)
Link to comment
Share on other sites

  • 4 months later...

I'm trying to determin why when i run the ammended script above or any other outlook com script i find it bottles out.

I get the Error: Varible must be of type "Object" the following line after '$objOutlook = ObjCreate("Outlook.Application")'

i'm able to use ExcelCOM_UDF.au3 with its ObjCreate("Excel.Application")' and it functions fine. The system i am on is

under certain user restrictions, i was unable to use the installer of autoit and had to use the zip pack.

$objOutlook = ObjCreate("Outlook.Application")
If Not IsObj($objOutlook) Then
    MsgBox(0, "", "no outlook object")
EndIf

... returns "no outlook object". suggestions anyone? i've tried compile to exe and run with simular fail.

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