Solved

Need to modify VB script in Outlook that currently saves attachments to a folder, but want it to then delete email message

Posted on 2009-03-30
3
338 Views
Last Modified: 2012-05-06
Running Exchange2003 and Outlook2003.  I have a client-side rule that moves emails from a certain sender into a folder called "Faxes", then runs a script that saves the attachments that are on the emails into a folder.  This works great, however, I would like to modify the script to delete the entire email after it has saved the attachment.  Can anyone help?  

Here is the script:
Sub SaveAttachmentToFolder(Item As Outlook.MailItem)
    Dim olkAttachment As Outlook.Attachment, _
        intCounter As Integer
    For intCounter = Item.Attachments.Count To 1 Step -1
        Set olkAttachment = Item.Attachments.Item(intCounter)
        'Change the folder name and path as desired
        olkAttachment.SaveAsFile "C:\Faxes 2009\" & olkAttachment.FileName
    Next
    Set olkAttachment = Nothing
End Sub


Thanks!
0
Comment
Question by:redmanjb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 250 total points
ID: 24024770
Hello redmanjb,



Regards,
Chris
Sub SaveAttachmentToFolder(Item As Outlook.MailItem)
    Dim olkAttachment As Outlook.Attachment, _
        intCounter As Integer
    For intCounter = Item.Attachments.Count To 1 Step -1
        Set olkAttachment = Item.Attachments.Item(intCounter)
        'Change the folder name and path as desired
        olkAttachment.SaveAsFile "C:\Faxes 2009\" & olkAttachment.FileName
    Next
    Set olkAttachment = Nothing
    item.delete
End Sub

Open in new window

0
 

Author Closing Comment

by:redmanjb
ID: 31564602
Yep, those two words did the trick!  Thank you very much for your prompt reply!  Cheers! :)
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24025024
Glad to help

Chris
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question