Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving E Mails
I have an excel sheet which part of it checks my inbox for e mails with
the subject of "manual handling questionnaire" it then moves it to a folder called manual, and then it is supposed to save the file in my h drive, but it all works except that it will not save the file into my h drive, the code is as follows:- Sub SaveAttachments() Dim olApp As Outlook.Application Dim olNs As Namespace Dim Fldr As MAPIFolder Dim MoveToFldr As MAPIFolder Dim olMi As MailItem Dim olAtt As Attachment Dim MyPath As String Dim i As Long Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") Set Fldr = olNs.GetDefaultFolder(olFolderInbox) Set MoveToFldr = Fldr.Folders("Manual") MyPath = "H:\My Documents" For i = Fldr.Items.Count To 1 Step -1 Set olMi = Fldr.Items(i) If InStr(1, olMi.Subject, "Manual Handling Questionnaire") 0 Then For Each olAtt In olMi.Attachments If olAtt.Filename = "Manual Handling .xls" Then olAtt.SaveAsFile MyPath & olMi.SenderName & ".xls" End If Next olAtt olMi.Save olMi.Move MoveToFldr End If Next i Set olAtt = Nothing Set olMi = Nothing Set Fldr = Nothing Set MoveToFldr = Nothing Set olNs = Nothing Set olApp = Nothing End Sub Anyone know where I am going wrong and could you point me in the right direction. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving E Mails
You need a back slash between the path to the folder and the beginning of
the file name. Steve "fee" wrote in message ups.com... I have an excel sheet which part of it checks my inbox for e mails with the subject of "manual handling questionnaire" it then moves it to a folder called manual, and then it is supposed to save the file in my h drive, but it all works except that it will not save the file into my h drive, the code is as follows:- Sub SaveAttachments() Dim olApp As Outlook.Application Dim olNs As Namespace Dim Fldr As MAPIFolder Dim MoveToFldr As MAPIFolder Dim olMi As MailItem Dim olAtt As Attachment Dim MyPath As String Dim i As Long Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") Set Fldr = olNs.GetDefaultFolder(olFolderInbox) Set MoveToFldr = Fldr.Folders("Manual") MyPath = "H:\My Documents" For i = Fldr.Items.Count To 1 Step -1 Set olMi = Fldr.Items(i) If InStr(1, olMi.Subject, "Manual Handling Questionnaire") 0 Then For Each olAtt In olMi.Attachments If olAtt.Filename = "Manual Handling .xls" Then olAtt.SaveAsFile MyPath & olMi.SenderName & ".xls" End If Next olAtt olMi.Save olMi.Move MoveToFldr End If Next i Set olAtt = Nothing Set olMi = Nothing Set Fldr = Nothing Set MoveToFldr = Nothing Set olNs = Nothing Set olApp = Nothing End Sub Anyone know where I am going wrong and could you point me in the right direction. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Coma between two e-mails | Excel Discussion (Misc queries) | |||
Finding e-mails | Excel Worksheet Functions | |||
send e-mails | Excel Discussion (Misc queries) | |||
e-mails addresses | Excel Worksheet Functions | |||
Saving Excel E Mails in a Word Folder | Setting up and Configuration of Excel |