I'm using the following code to set the currently selected folder in outlook
OutlookApp.ActiveExplorer().CurrentFolder = OlDefaultFolders.olFolderJunk;
There seems to be a type mismatch
Cannot implicitly convert type 'Microsoft.Office.Interop.Outlook.OlDefaultFolders' to 'Microsoft.Office.Interop.Outlook.MAPIFolder'
I have tried
OutlookApp.ActiveExplorer().CurrentFolder = (Outlook.MAPIFolder)OlDefaultFolders.olFolderJunk;
How can i solve this issue?
You are setting a property of type MAPIFolder
(which is a COM object) to a value of type OlDefaultFolders
(which is an int). You probably missed a call to Namespace.GetDefaultFolder
:
OutlookApp.ActiveExplorer().CurrentFolder = OutlookApp.Session.GetDefaultFolder(OlDefaultFolders.olFolderJunk);