Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-28-2021, 12:11 PM
tanko tanko is offline Macro to move reply message and original to folder Windows 10 Macro to move reply message and original to folder Office 2016
Novice
Macro to move reply message and original to folder
 
Join Date: Jan 2021
Posts: 17
tanko is on a distinguished road
Default Macro to move reply message and original to folder

I have a macro I use many times a day to move every message I send to a folder selected from a folder picker dialog (see below). I would like to modify it such that if the message is a reply to a message in my inbox folder, the message I am replying to should also be moved to that folder. Can you help me modify it? I wasn't able to figure it out on my own.




HTML Code:
Private Sub Application_ItemSend(ByVal Item As Object, _
    Cancel As Boolean)
  Dim objNS As NameSpace
  Dim objFolder As MAPIFolder
  Set objNS = Application.GetNamespace("MAPI")
  Set objFolder = objNS.PickFolder
  If TypeName(objFolder) <> "Nothing" And _
     IsInDefaultStore(objFolder) Then
      Set Item.SaveSentMessageFolder = objFolder
  End If
  Set objFolder = Nothing
  Set objNS = Nothing
End Sub

Public Function IsInDefaultStore(objOL As Object) As Boolean
  Dim objApp As Outlook.Application
  Dim objNS As Outlook.NameSpace
  Dim objInbox As Outlook.MAPIFolder
  On Error Resume Next
  Set objApp = CreateObject("Outlook.Application")
  Set objNS = objApp.GetNamespace("MAPI")
  Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
  Select Case objOL.Class
    Case olFolder
      If objOL.StoreID = objInbox.StoreID Then
        IsInDefaultStore = True
      End If
    Case olAppointment, olContact, olDistributionList, _
         olJournal, olMail, olNote, olPost, olTask
      If objOL.Parent.StoreID = objInbox.StoreID Then
        IsInDefaultStore = True
      End If
    Case Else
      MsgBox "This function isn't designed to work " & _
             "with " & TypeName(objOL) & _
             " items and will return False.", _
             , "IsInDefaultStore"
  End Select
  Set objApp = Nothing
  Set objNS = Nothing
  Set objInbox = Nothing
End Function
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Custom Form in Outlook 2016, for the Message setting 'Do not include original message' jsvictor1989@gmail.com Outlook 0 01-30-2019 10:54 PM
How to move easily a message to a conversation folder but not in Automatic mode yannouy Outlook 0 09-14-2017 10:04 AM
How to create a Quick Step to move message to a Public Folder ravl13 Outlook 0 05-03-2016 02:16 PM
Does Outlook reply to message sent to Junk folder? twixthecat Outlook 0 12-20-2012 03:59 AM
Macro to move reply message and original to folder Post reply into same folder as original message mfuggle Outlook 3 10-11-2011 03:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft