c# - Rename Folders in Outlook PST-File -


since few days i'm trying rename sent mail folder, deleted elements , inbox folder via c#.

i've tryed this:

 list<outlook.mailitem> mailitems = new list<outlook.mailitem>();             outlook.application app = new outlook.application();             outlook.namespace outlookns = app.getnamespace("mapi");             // add pst file (outlook data file) default profile             outlookns.addstore(pstfilepath);             outlook.mapifolder rootfolder = outlookns.stores[pstname].getrootfolder();             outlook.folders subfolders = rootfolder.folders;    foreach (outlook.folder folder in subfolders)             {                folder.name =  (folder.name == "deleted elements"?"deleted":folder.name); } 

but without success. exceptiion not have permissions change name. other custom created folders i'm able rename without problems.

is there unlock folder? or there other possibility access folders?

thanks lot

edit: expetion is: not have permissions.

public string renamefolder(string name, string folderid)     {         outlook.application app = new outlook.application();         outlook.namespace ns = null;         outlook.folder folder = null;         string n= null;          try         {             ns = app.getnamespace("mapi");             folder = ns.getfolderfromid(folderid) outlook.folder;             n=folder.name;             folder.name = (folder.name = name) ;             return n + " has been changed " + folder.name;         }         catch (system.exception ex)         {             throw ex;         }                 {             if (app != null)             {                 system.runtime.interopservices.marshal.finalreleasecomobject(app);             }              if (folder != null)             {                 system.runtime.interopservices.marshal.finalreleasecomobject(folder);             }              if (ns != null)             {                 system.runtime.interopservices.marshal.finalreleasecomobject(ns);             }         }     } 

this code working me..when run visual studio in administator mode..


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -