hutteto Posted March 25, 2010 Share Posted March 25, 2010 (edited) Hey I need to be able to open the file attachment in an email, but I cant figure out how to do it. Using the following code, I am able to count the number of attachments (in this case there is only 1 file) and then display the name of the attachment(s), but I cant open the attachment. I have removed allot of stuff not pertaining to the email attachment portion of my code, but bascially the below code loops through a mailbox and as long as there is an item in the inbox, it analyzes the email. Can anyone help me? expandcollapse popup$g_oOutlook = ObjCreate("Outlook.Application") $oOutlook = ObjCreate("Redemption.RDOSession") $ns = $g_oOutlook.GetNameSpace("MAPI") $oOutlook.MAPIOBJECT = $ns.MAPIOBJECT $oFolder = $oOutlook.getfolderfrompath("\\Mailbox - CAR/TN Reporting\Inbox") $mInbox = $oFolder.Items $Items = $mInbox.count $StartCount = $Items $Items = $mInbox.count ;Msgbox(0,"TOTAL EMAILS: ", "Items in Inbox: " & $Items) For $Item = $Items to 1 step -1 $EmailCategory = "" $CategoryFlag = "" $message = $mInbox.item($Item) $mSubject = $message.subject ;Msgbox(0,"Email Subject",$mSubject) $Number_of_Attachments = $message.Attachments.count ;MsgBox(0, "Autoit:", "The count of file attachments is: " & $Number_of_Attachments) ;Email Category Trigger #2 - REPORT_Audits If $CategoryFlag = 1 Then ;SKIP Else If StringInStr($mSubject, "Audit Res") >= 1 and $Number_of_Attachments >=1 Then For $att in $message.Attachments MsgBox(0, "Search result:", "The attachment file name is: " & $att.filename) FileOpen($att, 0) Next $EmailCategory = "REPORT_Audits" $CategoryFlag = 1 Else $CategoryFlag = 0 EndIf EndIf Next Edited March 26, 2010 by hutteto Link to comment Share on other sites More sharing options...
hutteto Posted March 26, 2010 Author Share Posted March 26, 2010 bump... Link to comment Share on other sites More sharing options...
BrettF Posted March 26, 2010 Share Posted March 26, 2010 Hutteto, Please remember to bump posts once every 24 hours (minimum). I believe your understanding of FileOpen is limited. FileOpen will open the file for either reading or writing. I believe you want to run it, so Run ($att) or ShellExecute ($att) should do the trick. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Juvigy Posted March 29, 2010 Share Posted March 29, 2010 There is a saveasfile method : http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.attachment.saveasfile.aspx You can save the attachment and then Shellexecute it. After you are finished you can close and delete it. This is what outlook do in general - when you double click attachment it saves it in the temporary outlook directory and then open it with the default program for that extension Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now