I am using VBA through Excel 365 to send the current workbook via Outlook email. It works fine, except that it only saves the message to the default sent items folder. I need the message to be saved in an alternate folder in Outlook. Cobbling together code from various sources, I came up with the following. The code runs without error, but the SaveSentMessage folder never gets updated. I don't know what I'm doing wrong.
Sub SendActiveWorkbookSavingToOtherFolder()
On Error Resume Next
Dim appOutlook As Object
Dim mItem As Object
Dim objNS As Object
Dim objFolder As Object
Set objNS = Application.getnamespace("MAPI")
Set appOutlook = GetObject(, "Outlook.Application") 'Bind to existing instance of Outlook
Set mItem = appOutlook.CreateItem(0) '<<---- number zero, not the letter
Set objFolder = objNS.GetDefaultFolder(5).Parent.Folders("Training") 'used value of 5 to get sent items default folder as shown at https://learn.microsoft.com/en-us/office/vba/api/outlook.oldefaultfolders
'objFolder always has a value of "Nothing" even after running the line above
'the folder "Training" is at the same level as Sent Items, Inbox, etc.
With mItem
.To = "******@domain.com"
.Subject = ActiveWorkbook.Name
.Attachments.Add ActiveWorkbook.FullName
.SaveSentMessageFolder = objFolder
.send
End With
'clean up objects
Set mItem = Nothing
Set appOutlook = Nothing
End Sub