Good morning all!!!
I am looking for some code that will search for a specific subject line and then take the attachment and save as an excel worksheet to a specified destination. I have been playing with the following code...
I keep getting block errors and even when I thought I resolved those errors and the macro runs, nothing happens. Here is some additional background. I get an email every Mon through Friday at 9am and the attachment is dated for the day before.
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMi As MailItem
Dim olAtt As Attachment
Dim Mypath As String
Dim i As Long
Dim InStr As Object
Set olApp = Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
Set MoveToFldr = Fldr.Folders("Repair Reports")
Mypath = "S:\Departments\Service & Production\Public\Repair Reports"
For i = Fldr.Items.Count To 1 Step -1
If olMi.Subject = "Daily repair report" Then
For Each olAtt In olMi.Attachments
If olAtt.Filename = "_repairs.csv" Then
Attachment.SaveAsFile Mypath & olMi.SenderName & ".xlsx"
Set olAtt = Nothing
Set olMi = Nothing
Set Fldr = Nothing
Set MoveToFldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
I received the email this morning(8/15) and the attachment is named...8-14-2012_repair report.csv
I would like to modify the code so it saves the file as just the date and as an excel file not a CSV file.
I look forward to your assistance!!!!!