检查Outlook文件夹是否存在 [英] Check if outlook folder exists
本文介绍了检查Outlook文件夹是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
跟随 vb.net代码,检查Outlook中是否存在ARS文件夹.
Following vb.net code checks if ARS folder exists in Outlook.
下面的代码效果很好.
但是我需要一个更好的代码.
But I need a better code.
更好的代码意味着不使用出错时跳转到语句.
Better code means without using On error goto statement.
推荐答案
VBA没有结构化的异常处理(C ++,C#,VB.Net中的try/catch或Delphi中的try/except).由于如果未找到指定的文件夹,则MAPIFolder.Folders.Item会引发异常,因此VBA只能使用出错时转到"来处理异常.
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".
在VBA.Net中,尝试以下操作(不在我的脑海):
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
这篇关于检查Outlook文件夹是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文