Reputation: 1
How to save the sent letter to the selected folder?
Item.SaveSentMessageFolder
doesn't work.
There are no errors during debug
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim message As String
Dim header As String
Dim selectFolderName As String
Dim selectFolderItem As Outlook.MAPIFolder
Dim oOutlook As New Outlook.Application
Dim MyData As DataObject
Set MyData = New DataObject
message = "Do you want to save the letter to a folder?"
header = "Save"
If MsgBox(message, vbYesNo + vbQuestion, header) = vbYes Then
SavePopUp.Show
MyData.GetFromClipboard
selectFolderName = MyData.GetText(1)
Set oNameSpace = oOutlook.GetNamespace("MAPI")
Set selectFolderItem = oNameSpace.Folders(1).Folders.Item("Projects").Folders.Item(selectFolderName)
Set Item.SaveSentMessageFolder = selectFolderItem
End If
End Sub
Upvotes: 0
Views: 192
Reputation: 12499
Is this what you are trying to do?
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim Select_Folder As folder
Dim message As String
message = "Do you want to save the letter to a folder?"
Dim header As String
header = "Save"
If TypeName(Item) = "MailItem" And Item.DeleteAfterSubmit = False Then
If MsgBox(message, vbYesNo + vbQuestion, header) = vbYes Then
'Display dialog box
Set Select_Folder = Application.Session.PickFolder
Set Item.SaveSentMessageFolder = Select_Folder
End If
End If
End Sub
Upvotes: 1
Reputation: 66255
Firstly, do not hardcode the store index (1). Access it by name.
Secondly, SaveSentMessageFolder can only be set to a folder from the same store where the message is residing.
Upvotes: 0