hi,
I would like to know if a directory exists in a pst file to know if I should create it.
the code is :
FolderInfoLoc = PstExport.RootFolder.GetSubFolder(“Contact”)
if “Contact” directory does not exist what is the return value ? “Nothing” does not work ?
The test would be:
if FolderInfoLoc=Nothing then 'PROBLEM
'Create th folder
FolderPST=Pst.CreatePredefinedFolder(“Contacts”, StandardIpmFolder.Contacts)
'Add the message
FolderPST.AddMessage(msgMAPIContact)
'or in a subfolder
SubFolderPST=FolderInfoPST.AddSubFolder(“Contact”)
'Add the message to the subfolder
SubFolderPST.AddMessage(msgMAPIContact)
end if
This code does not work. Why ?
thanks for your help
marc
Hi Marc,
Thank you for using Aspose.Email.
It seems you are getting error at the line:
If FolderInfoLoc = Nothing Then
Please have a look at the following lines of code for your kind reference. It opens a PST file and checks for the existence of a folder. If it doesn’t exist, then it creates this folder in the PST. Please let us know your feedback if this doesn’t solve your issue.
PersonalStorage pst = PersonalStorage.FromFile("Test1.pst");
FolderInfo folder = pst.RootFolder.GetSubFolder("Contacts");
if (folder == null)
{
pst.CreatePredefinedFolder("Contacts", StandardIpmFolder.Contacts);
}