Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
fee fee is offline
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coma between two e-mails Hemang Excel Discussion (Misc queries) 3 May 13th 10 10:30 PM
Finding e-mails James Excel Worksheet Functions 0 February 11th 09 11:15 AM
send e-mails bra863 Excel Discussion (Misc queries) 1 August 22nd 08 04:28 PM
e-mails addresses thd3 Excel Worksheet Functions 1 October 8th 07 09:20 PM
Saving Excel E Mails in a Word Folder HNL Setting up and Configuration of Excel 1 September 16th 06 10:23 AM


All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"