Microsoft Outlook 11.0

T

Tom

I run the following code once a day. If I don't manually go in and move the
files after i run the VB I have problems. What VB code can I use to move the
email to another folder within Microsoft Outlook when the Attachment has been
moved.




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
 

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