Felix_Dragonhammer
Board Regular
- Joined
- Apr 7, 2015
- Messages
- 117
I have this code:
Basically I was wondering how I would mark the email the code references as read after it's done with everything else it does.
Code:
Sub Save_and_Open_Source1(itm As Outlook.MailItem)
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim item As Object
Dim Atmt As Attachment
Set Atmt = Nothing
Dim File_Name As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set SubFolder = Inbox.Folders("IR GPAU Files")
For Each Atmt In SubFolder.Items(SubFolder.Items.Count).Attachments
'Check filename of each attachment and save if it has "xls" extension
If Right(Atmt.FileName, 4) = "xlsx" Then
'This path must exist! Change folder name as necessary.
Set FileName = Nothing
File_Name = "C:\Users\sberger\Desktop\GPAU\" & Atmt.FileName
Atmt.SaveAsFile File_Name
Dim xlApp As Object
Dim sourceWB As Object
Set xlApp = GetObject(, "Excel.Application")
With xlApp
.Visible = True
.EnableEvents = False
End With
Set sourceWB = xlApp.Workbooks.Open(File_Name, , False, , , , , , , True)
End If
Next Atmt
Call Check
End Sub
Basically I was wondering how I would mark the email the code references as read after it's done with everything else it does.