Check if outlook folder exists

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

Following vb.net code checks if ARS folder exists in Outlook.

Following code works very well.

But I need a better code.

Better code means without using On error goto statement.

回答1:

VBA does not have structured exception handling (try/catch in C++, C#, VB.Net or try/except in Delphi). Since MAPIFolder.Folders.Item raises an exception if the specified folder is not found, VBA can only handle exceptions using "on error goto".

In VBA.Net, try something like the following (off the top of my head):

Try    myNewFolder = myFolder.Folders("ARS") Catch   myNewFolder = myFolder.Folders.Add("ARS") End Try 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!