Sign in to follow this  
Followers 0
zimy

object has failed?

4 posts in this topic

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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Put Parentheses around the filename as in

CODE
$attachment.SaveAsFile($filename)

Tried that before and I couldnt get it to work... now it does... haha

Thanks for the help

Share this post


Link to post
Share on other sites

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.

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  
Followers 0