Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OUTLOOK Help? Auto Save attachments somewhere?

Status
Not open for further replies.

VulcanJedi

Technical User
Oct 2, 2002
430
US
I know VBA for XL, no outlook, can someone help? I wnt to set up a dummy email account and have all emails with attachments to store attachment in c:/saved_attachments or something?! Please let me know if this is possible and anybody that could help , cause I know no Outlook I would greatly appreciate. TIA

[yinyang] Tranpkp [pc2]
 
nevermind I think i figured it out myself


[yinyang] Tranpkp [pc2]
 
Merry Xmas?


Private Sub Application_NewMail()
Dim newMsg As Integer


Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)

c = myFolder.Items.Count

For newMsg = c To 1 Step -1

Set myitem = myFolder.Items(c)
Set myAttachments = myitem.Attachments
If myitem.UnRead = False Then Exit For
If myAttachments.Count > 0 Then


myitem.Display

Set myitem = myOlApp.ActiveInspector.CurrentItem
Set myAttachments = myitem.Attachments
myAttachments.Item(1).SaveAsFile "C:\Outlook Attachments\" & myAttachments.Item(1).DisplayName
myitem.Close olDiscard
Else
Exit Sub
End If
Next newMsg

End Sub


[yinyang] Tranpkp [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top