akhendre88
Board Regular
- Joined
- Sep 17, 2015
- Messages
- 76
Hello,
I have written a macro to go to the specific folder in inbox and read the latest mail and display it via msgbox, however I am not able to do the 2nd part i.e reading the mail body and display it through msgbox. Below is my code,
Please suggest.
Thank you
I have written a macro to go to the specific folder in inbox and read the latest mail and display it via msgbox, however I am not able to do the 2nd part i.e reading the mail body and display it through msgbox. Below is my code,
Code:
Sub chnageFolder()
Dim ns As Outlook.NameSpace
Dim exp As Outlook.Explorer
Dim myInbox As Folder, folder1 As Folder, folder2 As Folder
Dim myOlItems As Outlook.Items
Dim mItem As Outlook.mailItem
Set ns = Application.GetNamespace("MAPI")
Set exp = Application.ActiveExplorer
'Accessing the Inbox
Set myInbox = ns.GetDefaultFolder(olFolderInbox)
'Changing the current folder from inbox to Data Alerts
Set folder1 = myInbox.Folders.Item("Alerts").Folders.Item("Data Alerts")
Set exp.CurrentFolder = folder1
Set myOlItems = folder1.Items
If (mItem.UnRead = "True") Then
MsgBox mItem.Display
End If
End Sub
Please suggest.
Thank you