Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to delete attachments in Outlook 2003 sent items

Status
Not open for further replies.

ppuddick

ISP
Nov 15, 2002
56
GB
Hi there everyone,

Does anyone know of a vbscript that will allow me to delete attachments in the sent items folder in Outlook 2003? It would be good if this script could delete all attachments on sent items that are over a month old and keep the others.

I've just taken over a network where some of the pst files are "!!MASSIVE!!" and don't really want to go round every machine one by one.

Thank you in advance.
 
And what have you tried so far ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I have the following code from a book that works great with the inbox.


option explicit

dim oSession, oInBox, oMessage, oSender, sMsg, objAttachColl
dim oRecipients, thePath, oAddress, myAttach, oAttachment

'Path to Export Folder
thePath = "E:\Export\"

'Create Session
set oSession=CreateObject("MAPI.Session")
oSession.Logon "Microsoft Outlook"

set oInBox=oSession.InBox.Messages

on error resume next
Err.Clear

for each oMessage in oInBox
if oMessage.Attachments(1) = "" then
'do nothing no attachment
else
Set myAttach = oMessage.Attachments
for each oAttachment in myAttach
oAttachment.WriteToFile (thePath & oAttachment.name)
next
end if
next

oSession.Logoff
set oSession=nothing

WScript.echo "Exported Attachments"
WScript.quit


I must admit I'm a bit of a newb when it comes to vb. I have tried setting a dim of oSent but that doesn't work.

Thanks for replying by the way
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top