public static void Run() { // The path to the File directory. string dataDir = RunExamples.GetDataDir_Outlook(); string dst = dataDir + "PersonalStorage.pst"; // ExStart:LoadingFromStream // Create an instance of MapiMessage from file byte[] bytes = File.ReadAllBytes(dataDir + @"message.msg"); using (MemoryStream stream = new MemoryStream(bytes)) { stream.Seek(0, SeekOrigin.Begin); // Create an instance of MapiMessage from file MapiMessage msg = MapiMessage.FromStream(stream); // Get subject Console.WriteLine("Subject:" + msg.Subject); // Get from address Console.WriteLine("From:" + msg.SenderEmailAddress); // Get body Console.WriteLine("Body" + msg.Body); } // ExEnd:LoadingFromStream }
public static void Run() { // ExStart:RenderingContactInformationToMhtml string dataDir = RunExamples.GetDataDir_Outlook(); //Load VCF Contact and convert to MailMessage for rendering to MHTML MapiContact contact = MapiContact.FromVCard(dataDir + "Contact.vcf"); MemoryStream ms = new MemoryStream(); contact.Save(ms, ContactSaveFormat.Msg); ms.Position = 0; MapiMessage msg = MapiMessage.FromStream(ms); MailConversionOptions op = new MailConversionOptions(); MailMessage eml = msg.ToMailMessage(op); //Prepare the MHT format options MhtSaveOptions mhtSaveOptions = new MhtSaveOptions(); mhtSaveOptions.CheckBodyContentEncoding = true; mhtSaveOptions.PreserveOriginalBoundaries = true; MhtFormatOptions formatOp = MhtFormatOptions.WriteHeader | MhtFormatOptions.RenderVCardInfo; mhtSaveOptions.RenderedContactFields = ContactFieldsSet.NameInfo | ContactFieldsSet.PersonalInfo | ContactFieldsSet.Telephones | ContactFieldsSet.Events; mhtSaveOptions.MhtFormatOptions = formatOp; eml.Save(dataDir + "ContactMhtml_out.mhtml", mhtSaveOptions); // ExEnd:RenderingContactInformationToMhtml }
public static void Run() { string dataDir = RunExamples.GetDataDir_Outlook(); string fileName = dataDir + "MessageWithVotingButtons.msg"; using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(fileName))) { // ExStart:ReadingOnlyVotingButtons MapiMessage testMsg = MapiMessage.FromStream(ms); // This method can be useful when it is necessary to read only voting buttons Voting buttons will be introduced as a collection of string values IList buttons = FollowUpManager.GetVotingButtons(testMsg); // ExEnd:ReadingOnlyVotingButtons } }
public static void Run() { string dataDir = RunExamples.GetDataDir_Outlook(); string fileName = dataDir + "message3.msg"; // ExStart:ReplaceEmbeddedMSGAttachmentContents var message = MapiMessage.FromFile(fileName); var memeoryStream = new MemoryStream(); message.Attachments[2].Save(memeoryStream); var getData = MapiMessage.FromStream(memeoryStream); message.Attachments.Replace(1, "new 1", getData); // ExEnd:ReplaceEmbeddedMSGAttachmentContents message.Save(dataDir + "ReplaceEmbeddedMSGAttachmentContents_out.msg"); }
public static void Run() { string dataDir = RunExamples.GetDataDir_Outlook(); string fileName = dataDir + "message3.msg"; // ExStart:InsertMSGAttachmentAtSpecificlocation var message = MapiMessage.FromFile(fileName); var memoryStream = new MemoryStream(); message.Attachments[2].Save(memoryStream); var getData = MapiMessage.FromStream(memoryStream); message.Attachments.Insert(1, "new 11", getData); // ExEnd:InsertMSGAttachmentAtSpecificlocation message.Save(dataDir + "AttachmentAtSpecificlocation_out.msg"); }