Hi.
Maybe someone can help me with this code. This code is in an Outlook form that I use on a folder in Outlook called Import. The folder contains e-mails that all have Excel attachments. When the program runs, it loops through all the e-mails and makes a copy of their attachments, saving them in the folder "F:\Settlements\Import".
But there are two problems. It's saving the files in the Settlements folder and placing the word "Import" infront of the file name.
Also, I need to move the e-mails to a different folder after it has copied and pasted its attachments. I think the line:
objItem.Move 'New folder
Will work, but how do I enter the path of the new folder, which is an Outlook folder called Old??
Anyway, here is the code I'm using for the form. Thanks for any help anyone can give me!!!
D
option explicit
Function Item_Open()
dim objNameSpace
dim objFolder
dim objItem
dim objAttachment
dim intIndex
dim intIndex2
dim strFiles
set objNameSpace = Application.GetNameSpace("MAPI"
set objFolder = objNameSpace.PickFolder
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 "c:import\" & objAttachment.FileName
strFiles = strFiles & objAttachment.FileName & vbCR
end if
next
end if
next
Item.Body = strFiles
End Function
Maybe someone can help me with this code. This code is in an Outlook form that I use on a folder in Outlook called Import. The folder contains e-mails that all have Excel attachments. When the program runs, it loops through all the e-mails and makes a copy of their attachments, saving them in the folder "F:\Settlements\Import".
But there are two problems. It's saving the files in the Settlements folder and placing the word "Import" infront of the file name.
Also, I need to move the e-mails to a different folder after it has copied and pasted its attachments. I think the line:
objItem.Move 'New folder
Will work, but how do I enter the path of the new folder, which is an Outlook folder called Old??
Anyway, here is the code I'm using for the form. Thanks for any help anyone can give me!!!
D
option explicit
Function Item_Open()
dim objNameSpace
dim objFolder
dim objItem
dim objAttachment
dim intIndex
dim intIndex2
dim strFiles
set objNameSpace = Application.GetNameSpace("MAPI"
set objFolder = objNameSpace.PickFolder
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 "c:import\" & objAttachment.FileName
strFiles = strFiles & objAttachment.FileName & vbCR
end if
next
end if
next
Item.Body = strFiles
End Function