私は特定の件名のメールのための私の見通しからの受信トレイのいずれかを並べ替えると、(その表)メールの本文をコピーするコードを記述しようとしていますに体をコピーしますエクセルに入る。これは私がこれまで持っていたものです。コードを動作させることができず、検索する受信トレイを指定する方法がわからない助けをよろしく!VBAコードは、電子メールを検索し、Excel
Sub CopyEmail()
Dim olApp As Outlook.Application
Dim olNs As Outlook.Namespace
Dim olFldr As Outlook.MAPIFolder
Dim olItms As Outlook.Items
Dim olMail As Variant
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace(”MAPI”) 'get a runtime error here
Set olFldr = olNs.GetDefaultFolder(olFolderInbox)
Set olItms = olFldr.Items
Dim NLXemail As String
NLXemail = "Patient Receipts"
olItms.Sort NLXemail
If InStr(1, olMail.Subject, NLXemail, vbTextCompare) > 0 Then
ThisWorkbook.Sheets("Sheet1").Cells(3, 1).Value = outMail.Body
End If
Set olFldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub