Aspose.Email.Examples.CSharp.Email.Outlook.AccessContactInformation.Run C# (CSharp) Метод

Run() публичный статический Метод

public static Run ( ) : void
Результат void
        public static void Run()
        {
            // ExStart:AccessContactInformation
            // Load the Outlook file
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Load the Outlook PST file
            PersonalStorage personalStorage = PersonalStorage.FromFile(dataDir + "SampleContacts.pst");
            // Get the Contacts folder
            FolderInfo folderInfo = personalStorage.RootFolder.GetSubFolder("Contacts");
            // Loop through all the contacts in this folder
            MessageInfoCollection messageInfoCollection = folderInfo.GetContents();
            foreach (MessageInfo messageInfo in messageInfoCollection)
            {
                // Get the contact information
                MapiMessage mapi = personalStorage.ExtractMessage(messageInfo);

                MapiContact contact = (MapiContact)mapi.ToMapiMessageItem();

                // Display some contents on screen
                Console.WriteLine("Name: " + contact.NameInfo.DisplayName);
                // Save to disk in MSG format
                if (contact.NameInfo.DisplayName != null)
                {
                    MapiMessage message = personalStorage.ExtractMessage(messageInfo);
                    // Get rid of illegal characters that cannot be used as a file name
                    string messageName = message.Subject.Replace(":", " ").Replace("\\", " ").Replace("?", " ").Replace("/", " ");
                    message.Save(dataDir + "Contacts\\" + messageName + "_out.msg");
                }
            }
            // ExEnd:AccessContactInformation
        }
    }
AccessContactInformation