Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
344 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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
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: …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

650 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