Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Move attached messages (Outlook 2002 SP-2)

    Hi,
    I'm having one of those days so would appreciate any assistance. I have been forwarded several emails by a colleague, each of which has several emails attached to it (several hundred in some cases). I want to detach these emails and put them into some existing folders. I had assumed I could simply highlight them all and drag them into a folder but I get an error saying "Could not open one or more attachments". If dragged one by one, there is no problem with any of them but obviously I'd rather not have to do this for each of the several thousand items!
    Could this be caused by our archive software or does it just not work? Is it possible to do this with VBA - I have had a quick look but the attachments seem to be treated as generic attachments rather than mailitems so I cannot use the Move method on them.
    All ideas gratefully received!
    Thanks,
    Regards,
    Rory

    Microsoft MVP - Excel

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Ouch! I suspect a memory limitation here. and I'm even surprised your friend could attach that many. Some code could iterate through the attachment collection and copy them to another folder. It would have been better for your friend to create a pst file, copy the mail to it, and send you the zipped up pst. IMHO I'd suggest you explore that option because it would probably take less time in the long run, and you've got a better chance of getting it all in one piece.

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Thanks for the response!
    I have actually just started writing the code to copy the messages to a folder but I think I might simply break into his mailbox and copy the messages straight into my folders as there's a bit of a time issue! I'd be surprised if it were a memory issue though as I have 1GB installed, and I didn't have anything else running at the time. I will remember the pst idea for future reference - wouldn't have occurred to me!
    Thanks,
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Rory, are you not able to select them all (without opening them) and then use File, Move (or Copy) to Folder? Unless the e-mails are nested very deeply, in which case code would be the best solution, that works for me even on quite large and numerous message item attachments. Otherwise OldDog can write that code. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Yep, the PST as transport mechanism is definitely the way to go. Post that code when you have it done, so we can plagiarize. <img src=/S/smile.gif border=0 alt=smile width=15 height=15> I frequently have to deal with someone who will convert their messages to Word documents, including attachments, and then send them as a file attachment. It gets confusing.
    -John ... I float in liquid gardens
    UTC -7ąDS

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    John,
    I think we're talking at cross-purposes on this one! <img src=/S/grin.gif border=0 alt=grin width=15 height=15> I can move the messages as they are to a folder easily enough. I then want to detach every message attached to each message into that folder and that's where Outlook fails. I will finish the code when I get a spare moment - at current progress that should be around Summer 2009 (as I'm now a Claims Manager on top of everything else!).
    Thanks,
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    OK I confess I misunderstood you! However, doing that has no effect whatsoever if I choose Move to Folder... and if I choose Copy to Folder... it simply produces a copy of the "top-level" message. It may be because the attachments are in the message body? (which I probably should have mentioned at the start... <img src=/S/doh.gif border=0 alt=doh width=15 height=15>)
    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Just to make sure, I'm not talking about moving the "primary" (top-level) messages you rec'd, my suggestion is intended to apply to the inserted "sub-messages" They can be moved the same as top level messages. Apologies if you do know this, but I want to be sure:
    Open the "top level" message which has inserted messages. Select the inserted (attached) messages. Then use the File, Move to dialog. it works on inserted messages just as it does on regular "top-level" messages.

    If they are nested deeper than a couple of levels it'll be a pain. And the reason I was suggesting manually was the time it may take to write that code!
    -John ... I float in liquid gardens
    UTC -7ąDS

  9. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    <img src=/S/grovel.gif border=0 alt=grovel width=31 height=23> I'm sorry Rory, it appears that my suggestion doesn't work, I must have messed up in testing when I first posted it. The only way I can get this to work is to open each attached message and then use the File, Move toFolder dialog, which is a pain. Wanna post your code so far??
    -John ... I float in liquid gardens
    UTC -7ąDS

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Did you get any further with code on this? In Outlook 2000 VBA I tried and failed, because in OL 2000 there is no "Move to Folder" or "Copy to Folder" Method that I can see for a message Attachment. I was able to save the Attachments to file, but could not reimport them*, as it appears the only thing that can be imported into a MailItem is an Attachment! Maybe it can be done with CDO, but I don't know my way around CDO.

    Have I told you lately that I hate Outlooks' lack of exposure of its Object model?

    *Actually, I can reimport them manually by dragging and dropping from File Exporer, but not automatically. See immediately preceding comment. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    -John ... I float in liquid gardens
    UTC -7ąDS

  11. #11
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    I spent some time a long time ago trying to determine whether an attachment was an embedded mail item and, if so, whether I could assign it to a mail item object variable. I cannot remember the results of this experiment, but perhaps it's relevant to your situation. What happens if you try something like:

    Dim testMail as MailItem
    Set testMail = CurrentMessage.Attachments(1)

    Will it let you move testMail?

  12. #12
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    John,
    That's the way I started going (there's still no way I have found of moving an attachment to a folder in OL2002) - if I save them to a directory in the file system I can then (I think) use CDO's DropDirectory.GetMessages method to retrieve them. Will post code if I ever figure it out! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    I'm also going to try Jefferson's method, 'cos if that works it will be soooooo much easier!!
    Regards,
    Rory

    Microsoft MVP - Excel

  13. #13
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Jefferson, I can't set an AttachmentItem as a MailItem in OL 2000, I get a Type Mismatch error. FWIW here's my preliminary code. (There may be some unused Dimensions and I left in some commented code.) I hope I'm missing something simple!

    Sub DeNestInsertedMailItems()
    Dim nsNS As NameSpace
    Dim fldrSel As MAPIFolder
    Dim itmMessage As MailItem, itmAttMail As MailItem
    Dim attItem As Attachment
    Dim boolHasInsertedMail As Boolean
    Dim intC As Integer

    Set nsNS = Application.GetNamespace("MAPI")
    Set fldrSel = nsNS.PickFolder

    If Not fldrSel Is Nothing And fldrSel.DefaultItemType = olMailItem Then
    Do
    boolHasInsertedMail = False
    For Each itmMessage In fldrSel.Items
    If itmMessage.Attachments.Count Then
    For intC = itmMessage.Attachments.Count To 1 Step -1
    Set attItem = itmMessage.Attachments(intC)
    'MsgBox attItem.Class ' 5 = att, which tells that
    'attachments aren't recognized as any other intrinsic Outlook Class
    If Right(attItem.FileName, 4) = ".msg" Then
    boolHasInsertedMail = True
    Set itmAttMail = attItem 'Type mismatch
    ' move code would go here
    'attItem.Delete
    End If
    Next intC
    End If
    itmMessage.Save
    Next itmMessage
    Loop Until boolHasInsertedMail = False
    End If
    Set fldrSel = Nothing
    Set nsNS = Nothing
    End Sub
    -John ... I float in liquid gardens
    UTC -7ąDS

  14. #14
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    Nope I got no farther and have no usable new ideas. I dug out my test procedure and it had the same problem. My code was shorter, though:

    Sub aTest()
    Dim mlItem As MailItem, mlAttach As Attachment, mlNewMsg As MailItem
    Set mlItem = Application.ActiveInspector.CurrentItem
    Set mlAttach = mlItem.Attachments(1)
    'Set mlNewMsg = mlAttach 'type mismatch
    End Sub

    I just did a test myself with Outlook XP and I was able to select all and drag a copy of the four attached messages into my Deleted Items folder. Not sure why Rory's isn't working; maybe it's the sheer volume, or one of them has an issue, or...

  15. #15
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Move attached messages (Outlook 2002 SP-2)

    I later changed my code a bit to be closer to your Set ..statement and the problem remains. The rest of my code is a wrapper to examine all messages in a folder and to pull inserted messages out to the same folder, and to recurse through to see if they in turn have inserted messages, ad infinitum until there ain't any.

    If you read the thread you'll see that drag and drop seemed to work for me and I advised Rory to use it, but later I couldn't reproduce the behavior, and so withdrew my suggestion. I'm wondering if the technique works for only a limited number of inserted messages.
    -John ... I float in liquid gardens
    UTC -7ąDS

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •