A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Attatchment detach issues VB-Help



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 2nd 08, 03:07 PM posted to microsoft.public.outlook.program_vba
Rivers
external usenet poster
 
Posts: 16
Default Attatchment detach issues VB-Help

hi peeps thanks before hand for any help you can give,

i found this code on a website that pulls the attatchments off of the emails
and stores them into a specified folder. its brilliant except for a few tiny
gltches i have found.

1. All the emails are not being processed (i put a count in along with a
messagebox to check, i put 12 emails into the folder with only xls files but
ony 7 get transfered)
2. if the email hs multilple attatchments it only takes one

can anyone help with this? i have put below the code

thanks again

Rivers

For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
sel = SubFolder.Items.Count
MsgBox sel

If Right(Atmt.FileName, 3) = "xls" Then

FileName = "C:\Documents and Settings\me\My Documents\Email
Attachments\" & Atmt.FileName
Atmt.SaveAsFile FileName
Item.Move otherInbox.Folders("Flash Processed")
i = i + 1
End If
Next Atmt
Next Item
  #2  
Old July 2nd 08, 03:17 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Attatchment detach issues VB-Help

That code moves the item after processing the first attachment, so no others
can be processed. Also, in any loop where you're moving/deleting items from
a collection you should use a count down for loop, not for...each. The Items
collection count is changing as you move items so a for...each will process
only half the items in a collection:

For i = SubFolder.Items.Count To 1 Step -1

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rivers" wrote in message
...
hi peeps thanks before hand for any help you can give,

i found this code on a website that pulls the attatchments off of the
emails
and stores them into a specified folder. its brilliant except for a few
tiny
gltches i have found.

1. All the emails are not being processed (i put a count in along with a
messagebox to check, i put 12 emails into the folder with only xls files
but
ony 7 get transfered)
2. if the email hs multilple attatchments it only takes one

can anyone help with this? i have put below the code

thanks again

Rivers

For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
sel = SubFolder.Items.Count
MsgBox sel

If Right(Atmt.FileName, 3) = "xls" Then

FileName = "C:\Documents and Settings\me\My Documents\Email
Attachments\" & Atmt.FileName
Atmt.SaveAsFile FileName
Item.Move otherInbox.Folders("Flash Processed")
i = i + 1
End If
Next Atmt
Next Item


  #3  
Old July 2nd 08, 05:26 PM posted to microsoft.public.outlook.program_vba
Rivers
external usenet poster
 
Posts: 16
Default Attatchment detach issues VB-Help

ok ken being as though it was down to my thnking on my last query that caused
the problem in the first lace is this what you meant?
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments

If Right(Atmt.FileName, 3) = "xls" Then
FileName = "\\ Flash Recieved\" & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
End If
Next Atmt
Next Item

For Each Item In SubFolder.Items
Item.Move otherInbox.Folders("Flash Processed")
Next Item

however my attatchments all copy across but when it comes to my for lop to
move my items to a new folder it completes half then stops??

thanks before hand

Rivers

  #4  
Old July 3rd 08, 09:53 AM posted to microsoft.public.outlook.program_vba
Rivers
external usenet poster
 
Posts: 16
Default Attatchment detach issues VB-Help

thanks anyway figured it out needed a do loop wit a for statement

Do Until itemcheck = True
If SubFolder.Items.Count 0 Then
For Each Item In SubFolder.Items
Item.Move otherInbox.Folders("Flash Processed")
Next Item
Else
itemcheck = True
End If
Loop

works perfectly


"Rivers" wrote:

ok ken being as though it was down to my thnking on my last query that caused
the problem in the first lace is this what you meant?
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments

If Right(Atmt.FileName, 3) = "xls" Then
FileName = "\\ Flash Recieved\" & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
End If
Next Atmt
Next Item

For Each Item In SubFolder.Items
Item.Move otherInbox.Folders("Flash Processed")
Next Item

however my attatchments all copy across but when it comes to my for lop to
move my items to a new folder it completes half then stops??

thanks before hand

Rivers

  #5  
Old July 3rd 08, 02:55 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Attatchment detach issues VB-Help

You're still better off using the count down For loop I showed rather than a
For...Each loop. That's best practice when moving or deleting items from a
collection.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rivers" wrote in message
...
thanks anyway figured it out needed a do loop wit a for statement

Do Until itemcheck = True
If SubFolder.Items.Count 0 Then
For Each Item In SubFolder.Items
Item.Move otherInbox.Folders("Flash Processed")
Next Item
Else
itemcheck = True
End If
Loop

works perfectly


  #6  
Old July 3rd 08, 03:42 PM posted to microsoft.public.outlook.program_vba
Rivers
external usenet poster
 
Posts: 16
Default Attatchment detach issues VB-Help

Ken your right it doesnt work now it ran through once but now keeps giving
error

ive never written a step loop before can you help

Do Until SubFolder.Items.Count = 0
For Each Item In SubFolder.Items
Item.Move otherInbox.Folders("Flash Processed")
Next Item
Loop

"Ken Slovak - [MVP - Outlook]" wrote:

You're still better off using the count down For loop I showed rather than a
For...Each loop. That's best practice when moving or deleting items from a
collection.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Rivers" wrote in message
...
thanks anyway figured it out needed a do loop wit a for statement

Do Until itemcheck = True
If SubFolder.Items.Count 0 Then
For Each Item In SubFolder.Items
Item.Move otherInbox.Folders("Flash Processed")
Next Item
Else
itemcheck = True
End If
Loop

works perfectly



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Login Issues / Possible Password Authentication Issues D|an-0 Outlook - General Queries 0 December 21st 07 02:22 AM
Forward selected mail as attatchment Yallah Outlook and VBA 1 October 10th 07 06:02 AM
Detach an attachment? Frank D. Nicodem, Jr. Outlook Express 1 March 12th 07 05:44 PM
not using attatchment tony giannini Outlook Express 3 July 15th 06 03:21 PM
How do I forward email as an attatchment? Bill Outlook - General Queries 7 February 23rd 06 09:05 PM


All times are GMT +1. The time now is 05:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.