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!

moving attachments from outlook

Status
Not open for further replies.

ApplePirate

Programmer
Dec 16, 2002
65
GB
im hoping someone can help me,
Im new to VB and cant seem to get this code to work,
the code is available elsewhere on this site but im trying to get the code to only look in a specific folder
the folder "scottish southern" is in my inbox in outlook


---------------------------------------------------
Function Item_Open()
dim objNameSpace
dim objFolder
dim objItem
dim objAttachment
dim intIndex
dim intIndex2
dim strFiles
dim DefaultFolder
set DefaultFolder = Item.("Scottish Southern")
set objNameSpace = Application.GetNameSpace("MAPI")
set objFolder = objNameSpace.Folder
for intIndex = 1 to objFolder.Items.Count
set objItem = objFolder.Items(intIndex)
if objItem is nothing then
else
for intIndex2 = 1 to objItem.Attachments.Count
set objAttachment = objItem.Attachments(intIndex2)
if objAttachment is nothing then
else
objAttachment.SaveAsFile "T:\Developer Partnerships\File Loading Area\Quadrant\" & objAttachment.FileName
strFiles = strFiles & objAttachment.FileName & vbCR
end if
next
end if
next
Item.Body = strFiles
End Function
---------------------------------------------------

i get an error:-
Object required: '(string: "Scottish Southern")' Line No: 10

im trying to preset the folder that the code looks in to strip out attachments.

someone must be able to help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

 
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