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)
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.
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
Any help will be much appreciated.