If you don't hyet have an append query set up then create one and call the query something relevant ('Qry01_Append_Data' in my example).Īlmost finished, now go back to the VBA Editor in Outlook and specify the directory in the strDir variable and change the following code to match what you've created Once you've finished importing click the 'save import steps' check box and give the import routine a sensible name ('Import1' in my example). Create a new database (or move your existing one into the relevant directory) and import a file from your directory called 'Data.csv' and do whatever steps you have to to import the file the correct way. In the Step 3 screen add any exclusions you want and finally give your rule an appropriate name. On Step 1 choose the rules that suit your daily email such as a specific sender or subject and then on rule 2 choose 'run a script' and then in the 'Edit the rule description' box on the hyperlink choose the ExportFile macro which you just copy and pasted. Now within outlook click Tools>Rules and Alerts and then New Rule and choose 'Start from a blank rule" data-type="undefined" target="_blank"> 'Check messages when they arrive'. OutNewMail.Attachments(1).SaveAsFile strDir & 'Data.csv'ĪccApp.OpenCurrentDatabase strDir '& insert database name eg. Set outFolder = outNS.GetDefaultFolder(olFolderInbox) Public Sub ExportFile(MyMail As MailItem)