LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Dick K - Move e-mail to different folder

Hi Dick (or anyone else who may be able to help!),

I have some code below that copies the excel attachment from every e-mail in
an Outlook folder and saves it to a specified network drive. That part has
been working great. But then I tried to move the e-mail to a different
folder after it copies the attachment. In the Outlook folder, I currently
have ben testing with 4 files.....the code moves 2 of them to the different
outlook folder, while the other 2 stay. Any idea what I'm doing wrong?
Thanks!

Sub Move()
'Saves attachments to a specified folder

Dim ol As Outlook.Application
Dim ns As Namespace
Dim Fldr As MAPIFolder
Dim MoveToFldr As MAPIFolder
Dim Mi As MailItem
Dim Att As Attachment

Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")
Set Fldr = ns.Folders("Public Folders").Folders("All Public
Folders").Folders("Timesheet")
Set MoveToFldr = ns.Folders("Public Folders").Folders("All Public
Folders").Folders("Public Folders")

For Each Mi In Fldr.Items
If Mi.Attachments.Count 0 Then
For Each Att In Mi.Attachments
iFile = iFile + 1

'Att.SaveAsFile "H:\Timesheet Data\" & Att.Filename &
CStr(iFile)
'Att.SaveAsFile "H:\Timesheet Data\ts" & CStr(iFile) & ".xls"

Att.SaveAsFile "H:\Timesheet Data\" & Format(Mi.ReceivedTime,
"yyyymmddhhmmss") & "-" & CStr(iFile) & ".xls"

Next Att
Mi.Move MoveToFldr

End If
Next Mi

Set Att = Nothing
Set Mi = Nothing
Set Fldr = Nothing
Set ns = Nothing
Set ol = Nothing
Set MoveToFldr = Nothing

End Sub


 
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
Hunting Crashers with Dick Cheney mikeyboy82 Excel Discussion (Misc queries) 0 February 16th 06 09:56 PM
Move them to different folder Prasad Vanka Excel Programming 2 May 21st 04 01:50 PM
Move Folder Contents Dave Peterson[_3_] Excel Programming 2 May 10th 04 03:36 PM
Pivot Error: Thanks Dick Kusleika Alastair[_3_] Excel Programming 0 February 22nd 04 04:01 PM
Move file to different folder Don Guillett[_4_] Excel Programming 4 August 29th 03 07:35 PM


All times are GMT +1. The time now is 01:56 AM.

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"