Microsoft Office Forums Saving file attachments

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2005, 11:28 AM
Chief96 Chief96 is offline
Novice
Saving file attachments
 
Join Date: Dec 2005
Posts: 1
Chief96
Default Saving file attachments

Hello,
I have a script that is supposed to read from a specific Public Folder to strip off file attachments on incoming emails. I am sure the scipt is correct but it does not run when Outlook starts. The script is supposed to run automatically when a new item shows up in that Public Folder. Here is the script.
Thanks.
JM

Dim WithEvents NewMailItems As Outlook.Items
Private Sub Application_Startup()
Set NewMailItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderInbox).Items
End Sub

Private Sub NewMailItems_ItemAdd(ByVal msg As Object)

Dim myNS As NameSpace
Dim myInbox As MAPIFolder
Dim targetAttach As Attachment
Dim Dest As MAPIFolder
Dim f1 As MAPIFolder
Dim f2 As MAPIFolder


' Get a reference to the Inbox.
Set myNS = GetNamespace("MAPI")
Set myInbox = myNS.GetDefaultFolder(olFolderInbox)

Set Dest = Nothing

For Each f1 In myNS.Folders
For Each f2 In f1.Folders
If f2.Name = "Outgoing Messages" Then
Set Dest = f2
End If
Next
Next

'Process only mail messages.
If TypeOf msg Is MailItem Then

'Does this new message have any attachments?
For Each targetAttach In msg.Attachments

'Does this attachment have .oft in the filename?
If InStr(1, targetAttach.FileName, ".oft", vbTextCompare) > 0 Then

'Save off mail attachment and delete the message.
targetAttach.SaveAsFile "C:\DBUSAVE\" & targetAttach.DisplayName

msg.Delete



Exit For

End If

Next

End If

End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving file attachments Excel not saving all data and formatting TRT Excel 2 04-09-2009 12:51 PM
Saving Just one page.... derr04 Word 1 09-21-2007 10:46 AM
Saving only "DATA" on excel? No white bottom? jrasche2003@yahoo.com Excel 0 08-07-2006 09:27 AM
Attachments Ane Outlook 0 05-29-2006 04:09 AM
Daylight Saving Time Changed all appointments nemeth Outlook 0 04-10-2006 01:33 PM


All times are GMT -7. The time now is 04:59 AM.


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