Moving Email to other folders

T

Tom

I have a excel spreadsheet that is attached to an email
sent to me at least one a day. I use VB to move it to a
folder and imported to Access. What I want to happen is
when this email has been sent I want to move the email to
another folder. The reason being I am not sure what will
happen when they are two email messages left in the inbox.
Here is my VB statement.
Sub AttachmentImport()
On Error Resume Next
Dim ns As Namespace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
' MsgBox "Program is running"
DoCmd.Hourglass True

Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
'i = 0
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
If Atmt.FileName = "Grainger.xls"
Or "GrainRec.xls" Then
FileName = "\\wp01
\opendata\Antrim\Grainger\" & Atmt.FileName
Atmt.SaveAsFile FileName
' i = i + 1
End If
Next Atmt
Next Item
DoCmd.Hourglass False

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top