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
335 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
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
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 …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now