R
R
Roman Kazarov2020-02-26 01:57:09
Visual Basic
Roman Kazarov, 2020-02-26 01:57:09

How to save an email when sending?

I am writing a macro for Outlook VBA. You need to save the letter to the selected folder. The code passes without errors, but the letter is not saved where it should be.

o 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

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question