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

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

public static Run ( ) : void
Результат void
        public static void Run()
        {
            // ExStart:RemovePropertiesFromMSGAndAttachments
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage mapi = new MapiMessage("[email protected]", "[email protected]", "subject", "body");
            mapi.SetBodyContent("<html><body><h1>This is the body content</h1></body></html>", BodyContentType.Html);
            MapiMessage attachment = MapiMessage.FromFile(dataDir + @"message.msg");
            mapi.Attachments.Add("Outlook2 Test subject.msg", attachment);
            Console.WriteLine("Before removal = " + mapi.Attachments[mapi.Attachments.Count - 1].Properties.Count);

            mapi.Attachments[mapi.Attachments.Count - 1].RemoveProperty(923467779);// Delete anyone property
            Console.WriteLine("After removal = " + mapi.Attachments[mapi.Attachments.Count - 1].Properties.Count);
            mapi.Save(@"EMAIL_589265.msg");

            MapiMessage mapi2 = MapiMessage.FromFile(@"EMAIL_589265.msg");
            Console.WriteLine("Reloaded = " + mapi2.Attachments[mapi2.Attachments.Count - 1].Properties.Count);
            // ExEnd:RemovePropertiesFromMSGAndAttachments
        }
    }
RemovePropertiesFromMSGAndAttachments