문제

Person의 Outlook 프로필에 PST 파일을 프로그래밍 방식으로 추가하고 싶습니다. 여기에서 몇 가지 코드를 찾았습니다.

http://www.eggeadcafe.com/community/aspnet/65/10030171/try-cis-code.aspx

그것이 트릭이지만 여전히 의문을 남깁니다. "Outlook은 어디에이 장착 된 PST 파일 목록을 유지합니까?" 레지스트리에 있습니까? 어딘가에 구성 파일? 아무도?

도움이 되었습니까?

해결책

이는 버전에서 버전으로 변경 될 수있는 내부 구현 세부 사항입니다.

다른 팁

이 코드 (현재 프로젝트에서)는 유니 코드 및 비 유니 코드 PST 파일의 이름과 경로를 검색하고 디코딩합니다.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Win32;

namespace PSTRemoval_v2
{
    class PSTRReg
    {
        public RegistryKey regOPs, regPR, regCU, regCP, regCC;

        public Dictionary<string, string> OpenPSTs = new Dictionary<string, string>();

        public Dictionary<string, string> ClosedPSTs = new Dictionary<string, string>();

        public Dictionary<string, string> PurgedPSTs = new Dictionary<string, string>();

        public void ValidRegEntries(Outlook.Application olApp)
        {
            string prf = olApp.Session.CurrentProfileName;  // retrieve current Outlook profile name.  Needed in case user has multiple profiles

            regCU = Registry.CurrentUser;

            regOPs = regCU.CreateSubKey(String.Format(@"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\{0}",prf));

            regPR = regCU.CreateSubKey(String.Format(@"Software\WRT\OutlookAddins\PSTRemoval\{0}", prf));  // create a subkey in the registry for this profile

            regCC = regPR.CreateSubKey(@"ClosedPSTs");
            regCP = regPR.CreateSubKey(@"PurgedPSTs");
        }

        public void OpenPSTs_REG_Read()
        {
            PSTRNet regnet = new PSTRNet();
            regnet.EnumerateNetworkDrives();

            string[] sk = regOPs.GetSubKeyNames();
            foreach (string subkey in sk)
            {
                RegistryKey rk2 = regOPs.OpenSubKey(subkey);
                if (rk2.ValueCount > 0)
                {
                    string[] vn = rk2.GetValueNames();
                    Array.Sort(vn);

                    int bs = Array.BinarySearch(vn, "001f3001"); // search for the PST Name
                    int bs1 = Array.BinarySearch(vn, "001f3006"); // PST Name alternative
                    if ((bs > -1) || (bs1 > -1))
                    {
                        int bs2 = Array.BinarySearch(vn, "001f6700");  // search for the PST Path
                        if (bs2 > -1)
                        {
                            // decode the Name & Path to text strings
                            string PSTName;
                            try { PSTName = decode(vn[bs], rk2); }
                            catch { PSTName = decode(vn[bs1], rk2); }
                            string PSTPath = decode(vn[bs2], rk2);

                            if (regnet.PSTOnNet(PSTPath))  // add the PST to the list if it is on a network drive
                            {
                                try
                                {
                                    OpenPSTs.Add(PSTPath, PSTName);
                                }
                                catch { }
                                regOPs.DeleteSubKey(subkey);  // then delete the entry from the main part of the registry
                            }
                        }
                    }
                }
            }
        }

        public void PSTs_REG_Read(RegistryKey regkey, Dictionary<string, string> entries)
        {
            string[] RK = regkey.GetValueNames();
            if (RK.Length > 0)
                foreach (string ValueName in RK)
                    try { entries.Add(ValueName, regkey.GetValue(ValueName).ToString()); }
                    catch { }
        }

        public void PSTs_Reg_write(RegistryKey regKey, Dictionary<string, string> entries)
        {
            string[] RK_Delete = regKey.GetValueNames();
            if (RK_Delete.Length > 0)
                foreach (string ValueName in RK_Delete)
                    regKey.DeleteValue(ValueName);

            foreach (KeyValuePair<string, string> kvp in entries)
                regKey.SetValue(kvp.Key, kvp.Value);
        }

        private string decode(string value, RegistryKey rk)  // decode registry entries from Unicode to plain text
        {
            byte[] b = (byte[])rk.GetValue(value);


         return Encoding.Unicode.GetString(b);
            }
        }
    }
}

레지스트리 항목입니다 Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<ProfileName>

001F301은 유니 코드 PST의 이름입니다

그건 그렇고 레지스트리에 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top