Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-14-2014, 07:38 AM
terrymac terrymac is offline VBA Support required (trying to automatically filter PDFs from emails in specific folders. Windows XP VBA Support required (trying to automatically filter PDFs from emails in specific folders. Office 2007
Novice
VBA Support required (trying to automatically filter PDFs from emails in specific folders.
 
Join Date: Nov 2014
Posts: 8
terrymac is on a distinguished road
Default VBA Support required (trying to automatically filter PDFs from emails in specific folders.

I was hoping someone could help me, through google I have found this website.

Here is my problem; I am trying to do some VBA on my Outlook but I know nothing about it.

In my business we have specific documents that are emailed to us in PDF format, which over the coming years get updated. There are thousands of different attachments over thousands of emails, so I tried to use VB to strip the PDFs and then save them.

It all works but the one problem I have is if there is the same file, I need it to check the DATE MODIFIED of the file and overwrite if it is newer.... which would mean I will only be left with the latest of each file..



Here is my command is there a whiz out there who could tell me what to do?


Sub SaveAttachmentsToDisk(Item As Outlook.MailItem)
Dim olkFolder As Outlook.MAPIFolder, _
olkAttachment As Outlook.Attachment, _
objFSO As Object, _
strRootFolderPath As String, _
strFilename As String, _
intCount As Integer
'Change the following path to match your environment
strRootFolderPath = "Y:\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set olkFolder = Application.ActiveExplorer.CurrentFolder
If Item.Attachments.count > 0 Then
For Each olkAttachment In Item.Attachments
If objFSO.GetExtensionName(LCase(olkAttachment.FileNa me)) = "pdf" Then
strFilename = olkAttachment.FileName
intCount = 0
Do While True
If objFSO.FileExists(strRootFolderPath & strFilename) Then
intCount = intCount + 1
objFSO.deletefile (strRootFolderPath & strFilename)
Else
Exit Do
End If
Loop
olkAttachment.SaveAsFile strRootFolderPath & strFilename
End If
Next
End If
Set objFSO = Nothing
Set olkAttachment = Nothing
Set olkFolder = Nothing
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sent emails end up in both Sent and Draft folders Begadoc Outlook 2 11-26-2013 02:42 PM
How to set style automatically for specific texts ragesz Word 2 07-25-2013 07:08 AM
5 Folders Automatically Created under Inbox of Outlook 2007 yashwant Outlook 0 04-26-2012 12:28 AM
VBA Support required (trying to automatically filter PDFs from emails in specific folders. Merging outlook folders and emails rudihorvath Outlook 1 03-16-2012 07:03 AM
Current view filter applies automatically lumisy Outlook 3 03-25-2011 05:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft