none
Send a copy of an Inbox item to another folder while leaving the Inbox item intact RRS feed

  • Question

  • I want to send a copy of the InboxFolder.Items(iLoop).SenderEmailAddress that matches "someemail@email.com".

    I do not want to ".Move" it or ".Delete" it I want to send a copy to the "BillsFolder".

    Is it possible to send a copy of an Inbox item to another folder while leaving the Inbox item intact?

    Dim PersonFolder As Outlook.Folder Dim InboxFolder As Outlook.Folder Dim BillsFolder As Outlook.Folder Dim obj As Outlook.MailItem Set InboxFolder = Application.Session.GetDefaultFolder(olFolderInbox) Set PersonalFolder = InboxFolder.Parent Set BillsFolder = PersonalFolder.Folders("Bills") If InboxFolder.Items.Count = 0 Then Exit Sub For iLoop = InboxFolder.Items.Count To 1 Step -1 Set obj = InboxFolder.Items(iLoop) If (obj.SenderEmailAddress = "someemail@email.com") Then obj.??? BillsFolder Next iLoop


    Thursday, April 2, 2015 2:59 AM

Answers

  • set newObj = obj.Copy
    newObj.Move BillsFolder 
    


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by L.HlModerator Tuesday, April 14, 2015 2:07 PM
    Thursday, April 2, 2015 4:07 AM
  • Do not loop through all items in a folder, use Find/FindNext. Also avoid using multiple dot notation

    set vItems = InboxFolder.Items
    set obj = vItems.Find("[SenderEmailAddress] = 'someemail@email.com' ")
    while not (obj Is Nothing)
      ...
      set obj = vItems.FindNext
    wend


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!



    Thursday, April 2, 2015 4:21 AM

All replies

  • set newObj = obj.Copy
    newObj.Move BillsFolder 
    


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by L.HlModerator Tuesday, April 14, 2015 2:07 PM
    Thursday, April 2, 2015 4:07 AM
  • Do not loop through all items in a folder, use Find/FindNext. Also avoid using multiple dot notation

    set vItems = InboxFolder.Items
    set obj = vItems.Find("[SenderEmailAddress] = 'someemail@email.com' ")
    while not (obj Is Nothing)
      ...
      set obj = vItems.FindNext
    wend


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!



    Thursday, April 2, 2015 4:21 AM