Hi All,
I am running a Win 7 Enterprise machine, with MS Office 2013. I am looking to run a script that monitors a specific email folder in Outlook, waits for emails to hit the folder, then saves the attachment on the email to a specific folder on the network.
Is this possible without using VB?
Thanks,
ADP
Removing Attachment from Email
Moderators: Dorian (MJT support), JRL, Phil Pendlebury
-
- Pro Scripter
- Posts: 70
- Joined: Sun May 03, 2009 11:49 pm
- Location: AU
Re: Removing Attachment from Email
Hi ADP,
You could get away with out VB scripts with example below. NOTE: you will need to create your own error handles and define the folder names to look for. Working for me so far.
PS: Am running W7 enterprise with MS outlook 2010
You could get away with out VB scripts with example below. NOTE: you will need to create your own error handles and define the folder names to look for. Working for me so far.
PS: Am running W7 enterprise with MS outlook 2010
Code: Select all
Let>n=0
Let>i=0
Let>dirAtt=C:\Temp\att\
Repeat>i
Add>i,1
Let>appTitle=Outlook
'--------------------------------
'Click Object Tab Send / Receive
'--------------------------------
Let>appTitle=Outlook
GoSub>Get_AppName
GoSub>Get_WinHandle
SetFocus>%hWndResult%
UIClick>%hWndResult%,{"Send / Receive"}
Wait>0.5
WaitReady>0
'-----------------------------------------------
'Click Object Button Send / Receive All Folders
'-----------------------------------------------
GoSub>Get_AppName
GoSub>Get_WinHandle
UIClick>%hWndResult%,{"Send/Receive All Folders"}
WaitReady>0
'-----------------------------------------------
'Select Object Folder named Test
'Define your folder name here
'-----------------------------------------------
GoSub>Get_AppName
GoSub>Get_WinHandle
UISelect>%hWndResult%,{"Folders"}
WaitReady>0
'-----------------------------------------------
'Select Object Folder named Test
'**Define your folder name here**
'-----------------------------------------------
GoSub>Get_AppName
GoSub>Get_WinHandle
UISelect>%hWndResult%,{"Test"}
WaitReady>0
'-----------------------------------------------
'Check for email
'-----------------------------------------------
GoSub>Get_AppName
GoSub>Get_WinHandle
Let>ObjName=SUPERGRID
Let>ObjIndex=2
Let>getText=1
GoSub>Get_WindowObjectVars
Position>There are no items,%wText%,1,iPos
If>iPos>0
'Wait to delay next lookup
Wait>5
Else
'There may be an email with attachments
'--------------------------------
'Click Object File Tab
'--------------------------------
GoSub>Get_AppName
GoSub>Get_WinHandle
SetFocus>%hWndResult%
UIClick>%hWndResult%,{"File Tab"}
Wait>0.5
WaitReady>0
'--------------------------------
'Click Object Save Attachments
'--------------------------------
GoSub>Get_AppName
GoSub>Get_WinHandle
SetFocus>%hWndResult%
UIClick>%hWndResult%,{"Save Attachments"}
Wait>0.5
WaitReady>0
Let>appTitle=Attachments
'--------------------------------
'Click Object button OK
'--------------------------------
GoSub>Get_AppName
If>iPos>0
GoSub>Get_WinHandle
SetFocus>%hWndResult%
UIClick>%hWndResult%,{"OK"}
Wait>0.5
WaitReady>0
'--------------------------------
'Assign Object Folder name:
'First gerenate a unique folder
'in case file names are the same
'--------------------------------
Random>500000,ran
Day>d
Month>m
Year>y
Let>dirAttSave=%dirAtt%%d%%m%%y%_%ran%
CreateDir>dirAttSave
GoSub>Get_WinHandle
SetFocus>%hWndResult%
UISetValue>%hWndResult%,{"Folder name:"},%dirAttSave%
Wait>0.5
WaitReady>0
'--------------------------------
'Click Object button OK
'--------------------------------
GoSub>Get_WinHandle
SetFocus>%hWndResult%
UIClick>%hWndResult%,{"OK"}
Wait>1
WaitReady>0
'--------------------------------
'Click Object SUPERGRID
'--------------------------------
Let>appTitle=Outlook
GoSub>Get_AppName
GoSub>Get_WinHandle
Let>ObjName=SUPERGRID
Let>ObjIndex=2
GoSub>Get_WindowObjectVars
SetFocus>%ObjhWnd%
Wait>0.5
WaitReady>0
'------------------------------------
'DELETE EMAIL or create code to move?
'------------------------------------
Press Del
Wait>1
WaitReady>0
Else
'has no attachments
Press Esc
Wait>1
WaitReady>0
'--------------------------------
'Click Object SUPERGRID
'--------------------------------
Let>appTitle=Outlook
GoSub>Get_AppName
GoSub>Get_WinHandle
Let>ObjName=SUPERGRID
Let>ObjIndex=2
GoSub>Get_WindowObjectVars
SetFocus>%ObjhWnd%
Wait>0.5
WaitReady>0
'------------------------------------
'DELETE EMAIL or create code to move?
'------------------------------------
Press Del
Wait>1
WaitReady>0
EndIf
EndIf
Until>i=%n%
SRT>Get_AppName
'------------------
'Get Title-AppName
'------------------
Let>WIN_USEHANDLE=0
GetWindowList>wList
Separate>%wList%,%CRLF%,wList
Let>i=0
Repeat>i
Add>i,1
Let>lVal=wList_%i%
Position>%appTitle%,%lVal%,1,iPos
If>iPos>0
Let>appName=%lVal%
Let>i=%wList_Count%
EndIf
Until>i=%wList_Count%
END>Get_AppName
SRT>Get_WinHandle
Let>WIN_USEHANDLE=0
Let>hWndResult=%
GetWindowHandle>%appName%,hWndResult
Let>WIN_USEHANDLE=1
END>Get_WinHandle
SRT>Get_WindowObjectVars
'-------------------------------------------
'RETURN VALUES FROM SPEICIFIED OBJECT
'E.G DATAGRID,FIELD,LABEL ETC
'-------------------------------------------
'If>getText=1 Returns wText with the text in the object
'X1,Y1,X2,Y2 returns the position of the DATAGRID on the screen
'ObjhWnd returns handle of object
FindObject>%hWndResult%,%ObjName%,,%ObjIndex%,ObjhWnd,X1,Y1,X2,Y2,result
'set x y and bottom pos of Object
Let>posX=%X1%+10
Let>posY=%Y1%+10
Let>posB=%Y2%
Let>WIN_USEHANDLE=1
If>getText=1
GetTextInit
'Capture text for the object using the returned ObjhWnd handle
GetWindowTextEx>%ObjhWnd%,wText
Let>getText=0
EndIF
END>Get_WindowObjectVars
Loving MS's Capabilities!!!
Re: Removing Attachment from Email
I'll give this a shot - thanks!
ADP
ADP