Excel VBA to save email after sent, but only show preview email and not sent email

ngadiez123

New Member
Joined
Oct 23, 2018
Messages
2
I want to save the email in my local folder, and I saw this link https://www.mrexcel.com/forum/excel-questions/361751-vba-saving-email-only-after-send-pushed.html which basically use the class module to save the email after sending it out. However the problem is, the email saved is the preview email (email that is being displayed before you send the email) instead of sent email (email in which you cannot edit anything anymore)


Code:
Dim cls_OL As New clsOutlook
Public objMail_SentMsg As Object
Public Emailpath As String


Sub SendEmail()
    Dim OutMail As Object
    Set cls_OL.obj_OL = CreateObject("Outlook.Application")
    cls_OL.obj_OL.Session.Logon
    Set OutMail = cls_OL.obj_OL.CreateItem(0)
    Set objMail_SentMsg = OutMail
    Emailpath = "V:\test\emailname.msg"
    With OutMail
    On Error Resume Next
        'Assume this all strings variables are fine
        .HTMLBody = "Hi User, regards"
        .to = "test@email.com"
        .CC = vbnullstring
        .BCC = vbnullstring
        .Subject = "This is a test message"
        .Display
    End With
    Set OutMail = Nothing
End Sub


Option Explicit
Public WithEvents obj_OL As Outlook.Application
Private Sub obj_OL_ItemSend(ByVal Item As Object, Cancel As Boolean)
    item.SaveAs Emailpath
    Set obj_OL = Nothing
End Sub
However, the email that is being saved is not a sent email ( the one where you cannot edit it anymore) but is a preview/draft email(the one that you can edit before you send email)


Any help will be much appreciated.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top