Я пытался сохранить текущую электронную почту в папку.
Я немного изменил свой код. Однако есть ошибка.
*438 : object doesn't support this property or method.*
по этому коду:
GetCurrentItem().SaveAsFile StrFile, olMSG
Мой код VBA:
Public fso As New FileSystemObject
Public objApp As Outlook.Application
Public OutMail As Outlook.MailItem
Public strPath As String
Public StrFile As String
Function GetCurrentItem() As Object
Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
Set objApp = Nothing
End Function
Sub saveMyEmail()
strPath = "C:\Users\admin\Desktop\my vba\fso\"
StrFile = strPath & Worksheets("Main").Range("A1").Value & ".msg"
GetCurrentItem().SaveAsFile StrFile, olMSG
Set fso = Nothing
End Sub