Beispiel #1
0
        /// <summary>
        /// This is a recursive method to display contents of a folder
        /// </summary>
        /// <param name="folderInfo"></param>
        /// <param name="pst"></param>
        private static void ExtractMsgFiles(FolderInfo folderInfo, PersonalStorage pst)
        {
            // ExStart:ExtractMessagesFromPSTFileExtractMsgFiles
            // display the folder name
            Console.WriteLine("Folder: " + folderInfo.DisplayName);
            Console.WriteLine("==================================");
            // loop through all the messages in this folder
            MessageInfoCollection messageInfoCollection = folderInfo.GetContents();

            foreach (MessageInfo messageInfo in messageInfoCollection)
            {
                Console.WriteLine("Saving message {0} ....", messageInfo.Subject);
                // get the message in MapiMessage instance
                MapiMessage message = pst.ExtractMessage(messageInfo);
                // save this message to disk in msg format
                message.Save(message.Subject.Replace(":", " ") + ".msg");
                // save this message to stream in msg format
                MemoryStream messageStream = new MemoryStream();
                message.Save(messageStream);
            }

            // Call this method recursively for each subfolder
            if (folderInfo.HasSubFolders == true)
            {
                foreach (FolderInfo subfolderInfo in folderInfo.GetSubFolders())
                {
                    ExtractMsgFiles(subfolderInfo, pst);
                }
            }
            // ExEnd:ExtractMessagesFromPSTFileExtractMsgFiles
        }
Beispiel #2
0
        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
        }
        public static void Run()
        {
            //ExStart:SetMAPIProperties
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create a sample Message
            MapiMessage mapiMsg = new MapiMessage("*****@*****.**", "*****@*****.**", "This is subject", "This is body");

            // Set multiple properties
            mapiMsg.SetProperty(new MapiProperty(MapiPropertyTag.PR_SENDER_ADDRTYPE_W, Encoding.Unicode.GetBytes("EX")));
            MapiRecipient recipientTo = mapiMsg.Recipients[0];
            MapiProperty propAddressType = new MapiProperty(MapiPropertyTag.PR_RECEIVED_BY_ADDRTYPE_W, Encoding.UTF8.GetBytes("MYFAX"));
            recipientTo.SetProperty(propAddressType);
            string faxAddress = "My Fax User@/FN=fax#/VN=voice#/CO=My Company/CI=Local";
            MapiProperty propEmailAddress = new MapiProperty(MapiPropertyTag.PR_RECEIVED_BY_EMAIL_ADDRESS_W, Encoding.UTF8.GetBytes(faxAddress));
            recipientTo.SetProperty(propEmailAddress);
            mapiMsg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT | MapiMessageFlags.MSGFLAG_FROMME);
            mapiMsg.SetProperty(new MapiProperty(MapiPropertyTag.PR_RTF_IN_SYNC, BitConverter.GetBytes((long)1)));

            // Set DateTime property
            MapiProperty modificationTime = new MapiProperty(MapiPropertyTag.PR_LAST_MODIFICATION_TIME, ConvertDateTime(new DateTime(2013, 9, 11)));
            mapiMsg.SetProperty(modificationTime);
            mapiMsg.Save(dataDir + "MapiProp_out.msg");
            //ExEnd:SetMAPIProperties
        }
        static void Main(string[] args)
        {
            string pstFilePath = "sample.pst";

            // Create an instance of PersonalStorage and load the PST from file
            using (PersonalStorage personalStorage = PersonalStorage.FromFile(pstFilePath))
            {
                // Get the list of subfolders in PST file
                FolderInfoCollection folderInfoCollection = personalStorage.RootFolder.GetSubFolders();
                // Traverse through all folders in the PST file
                // TODO: This is not recursive
                foreach (FolderInfo folderInfo in folderInfoCollection)
                {
                    // Get all messages in this folder
                    MessageInfoCollection messageInfoCollection = folderInfo.GetContents();
                    // Loop through all the messages in this folder
                    foreach (MessageInfo messageInfo in messageInfoCollection)
                    {
                        // Extract the message in MapiMessage instance
                        MapiMessage message = personalStorage.ExtractMessage(messageInfo);
                        Console.WriteLine("Saving message {0} ....", message.Subject);
                        // Save the message to disk in MSG format
                        // TODO: File name may contain invalid characters [\ / : * ? " < > |]
                        message.Save(@"\extracted\" + message.Subject + ".msg");
                    }
                }
            }
        }
Beispiel #5
0
        public static void ReadAndReplaceMessageBody()
        {
            // String path = @"C:\Email\";
            MapiMessage msg = MapiMessage.FromFile("Test Links.msg");

            String URLToReplace = "www.aspose.com";

            if (msg.BodyType == BodyContentType.Html)
            {
                //Extract HTML Body
                var bodyHtml = msg.BodyHtml;

                //Setting Regex for finding hyperlink
                Regex rs = new Regex(@"<a.*?href=(""|')(?<href>.*?)(""|').*?>(?<value>.*?)</a>");

                foreach (Match match in rs.Matches(bodyHtml))
                {
                    //Extrct URL
                    string url = match.Groups["href"].Value;

                    //Replace URL
                    bodyHtml = bodyHtml.Replace(url, URLToReplace);
                }

                //Setting new body
                msg.Body = bodyHtml;
            }

            //Save MSG
            Aspose.Email.SaveOptions options = new MsgSaveOptions(MailMessageSaveType.OutlookMessageFormatUnicode);
            msg.Save(@"Test Links_SavedMsg.msg", options);
        }
        public static void Run()
        {
            // The path to the File directory.
            string dataDir  = RunExamples.GetDataDir_Email();
            string dstEmail = dataDir + "New-Draft.msg";

            // Create a new instance of MailMessage class
            MailMessage message = new MailMessage();

            // Set sender information
            message.From = "*****@*****.**";

            // Add recipients
            message.To.Add("*****@*****.**");
            message.To.Add("*****@*****.**");

            // Set subject of the message
            message.Subject = "New message created by Aspose.Email";

            // Set Html body of the message
            message.IsBodyHtml = true;
            message.HtmlBody   = "<b>This line is in bold.</b> <br/> <br/><font color=blue>This line is in blue color</font>";

            // Create an instance of MapiMessage and load the MailMessag instance into it
            MapiMessage mapiMsg = MapiMessage.FromMailMessage(message);

            // Set the MapiMessageFlags as UNSENT and FROMME
            mapiMsg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT | MapiMessageFlags.MSGFLAG_FROMME);

            // Save the MapiMessage to disk
            mapiMsg.Save(dstEmail);

            Console.WriteLine(Environment.NewLine + "Created draft MSG at " + dstEmail);
        }
Beispiel #7
0
        public static void Run()
        {
            // ExStart:DraftAppointmentRequest
            // The path to the File directory.
            string dataDir  = RunExamples.GetDataDir_Email();
            string dstDraft = dataDir + "appointment-draft_out.msg";

            string sender    = "*****@*****.**";
            string recipient = "*****@*****.**";

            MailMessage message = new MailMessage(sender, recipient, string.Empty, string.Empty);

            Appointment app = new Appointment(string.Empty, DateTime.Now, DateTime.Now, sender, recipient)
            {
                MethodType = AppointmentMethodType.Publish
            };

            message.AddAlternateView(app.RequestApointment());

            MapiMessage msg = MapiMessage.FromMailMessage(message);

            // Save the appointment as draft.
            msg.Save(dstDraft);

            Console.WriteLine(Environment.NewLine + "Draft saved at " + dstDraft);
            // ExEnd:DraftAppointmentRequest
        }
Beispiel #8
0
        public static void Run()
        {
            // ExStart:CreateDraftAppointmentFromText
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_KnowledgeBase();
            string ical    = @"BEGIN:VCALENDAR
METHOD:PUBLISH
PRODID:-//Aspose Ltd//iCalender Builder (v3.0)//EN
VERSION:2.0
BEGIN:VEVENT
ATTENDEE;[email protected]:mailto:[email protected]
DTSTART:20130220T171439
DTEND:20130220T174439
DTSTAMP:20130220T161439Z
END:VEVENT
END:VCALENDAR";

            string        sender    = "*****@*****.**";
            string        recipient = "*****@*****.**";
            MailMessage   message   = new MailMessage(sender, recipient, string.Empty, string.Empty);
            AlternateView av        = AlternateView.CreateAlternateViewFromString(ical, new ContentType("text/calendar"));

            message.AlternateViews.Add(av);
            MapiMessage msg = MapiMessage.FromMailMessage(message);

            msg.Save(dataDir + "DraftAppointmentFromText_out.msg");
            // ExEnd:CreateDraftAppointmentFromText
        }
Beispiel #9
0
        public static void Run()
        {
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();
            string dst     = dataDir + "message.msg";

            // Create an instance of MailMessage class
            MailMessage mailMsg = new MailMessage();

            // Set FROM field of the message
            mailMsg.From = "*****@*****.**";

            // Set TO field of the message
            mailMsg.To.Add("*****@*****.**");

            // Set SUBJECT of the message
            mailMsg.Subject = "creating an outlook message file";

            // Set BODY of the message
            mailMsg.Body = "This message is created by Aspose.Email";

            // Create an instance of MapiMessage class and pass MailMessage as argument
            MapiMessage outlookMsg = MapiMessage.FromMailMessage(mailMsg);

            // Save the message (msg) file
            outlookMsg.Save(dst);

            Console.WriteLine(Environment.NewLine + "MSG saved successfully at " + dst);
        }
Beispiel #10
0
        public static void Run()
        {
            //ExStart:ReadAndWritingOutlookTemplateFile
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Load the Outlook template (OFT) file in MailMessage's instance
            MailMessage message = MailMessage.Load(dataDir + "sample.oft", new MsgLoadOptions());

            // Set the sender and recipients information
            string senderDisplayName     = "John";
            string senderEmailAddress    = "*****@*****.**";
            string recipientDisplayName  = "William";
            string recipientEmailAddress = "*****@*****.**";

            message.Sender = new MailAddress(senderEmailAddress, senderDisplayName);
            message.To.Add(new MailAddress(recipientEmailAddress, recipientDisplayName));
            message.HtmlBody = message.HtmlBody.Replace("DisplayName", "<b>" + recipientDisplayName + "</b>");

            // Set the name, location and time in email body
            string meetingLocation = "<u>" + "Hall 1, Convention Center, New York, USA" + "</u>";
            string meetingTime     = "<u>" + "Monday, June 28, 2010" + "</u>";

            message.HtmlBody = message.HtmlBody.Replace("MeetingPlace", meetingLocation);
            message.HtmlBody = message.HtmlBody.Replace("MeetingTime", meetingTime);

            // Save the message in MSG format and open in Office Outlook
            MapiMessage msg = MapiMessage.FromMailMessage(message);

            msg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);
            msg.Save(dataDir + "ReadAndWritingOutlookTemplateFile_out.msg");
            //ExEnd:ReadAndWritingOutlookTemplateFile
        }
        public static void Run()
        {
            //ExStart:SetMAPIProperties
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create a sample Message
            MapiMessage mapiMsg = new MapiMessage("*****@*****.**", "*****@*****.**", "This is subject", "This is body");

            // Set multiple properties
            mapiMsg.SetProperty(new MapiProperty(MapiPropertyTag.PR_SENDER_ADDRTYPE_W, Encoding.Unicode.GetBytes("EX")));
            MapiRecipient recipientTo     = mapiMsg.Recipients[0];
            MapiProperty  propAddressType = new MapiProperty(MapiPropertyTag.PR_RECEIVED_BY_ADDRTYPE_W, Encoding.UTF8.GetBytes("MYFAX"));

            recipientTo.SetProperty(propAddressType);
            string       faxAddress       = "My Fax User@/FN=fax#/VN=voice#/CO=My Company/CI=Local";
            MapiProperty propEmailAddress = new MapiProperty(MapiPropertyTag.PR_RECEIVED_BY_EMAIL_ADDRESS_W, Encoding.UTF8.GetBytes(faxAddress));

            recipientTo.SetProperty(propEmailAddress);
            mapiMsg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT | MapiMessageFlags.MSGFLAG_FROMME);
            mapiMsg.SetProperty(new MapiProperty(MapiPropertyTag.PR_RTF_IN_SYNC, BitConverter.GetBytes((long)1)));

            // Set DateTime property
            MapiProperty modificationTime = new MapiProperty(MapiPropertyTag.PR_LAST_MODIFICATION_TIME, ConvertDateTime(new DateTime(2013, 9, 11)));

            mapiMsg.SetProperty(modificationTime);
            mapiMsg.Save(dataDir + "MapiProp_out.msg");
            //ExEnd:SetMAPIProperties
        }
        public static void Run()
        {
            // ExStart:DeletVotingButtonFromMessage
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create New Message and set FollowUpOptions, FollowUpManager properties
            MapiMessage msg = CreateTestMessage(false);

            FollowUpOptions options = new FollowUpOptions();

            options.VotingButtons = "Yes;No;Maybe;Exactly!";
            FollowUpManager.SetOptions(msg, options);
            msg.Save(dataDir + "MapiMsgWithPoll.msg");
            FollowUpManager.RemoveVotingButton(msg, "Exactly!"); // Deleting a single button OR
            FollowUpManager.ClearVotingButtons(msg);             // Deleting all buttons from a MapiMessage
            msg.Save(dataDir + "MapiMsgWithPoll.msg");
            // ExEnd:DeletVotingButtonFromMessage
        }
Beispiel #13
0
        public static void Run()
        {
            string      dataDir = RunExamples.GetDataDir_Outlook();
            MapiMessage msg     = MapiMessage.FromFile(dataDir + "MsgWithAtt.msg");

            msg.Save(dataDir + "AttachmentsToRemove_out.msg");

            // ExStart:RemoveAttachmentsFromFile
            MapiMessage.RemoveAttachments(dataDir + "AttachmentsToRemove_out.msg");
            // ExEnd:RemoveAttachmentsFromFile
        }
Beispiel #14
0
        public static void Run()
        {
            string      dataDir = RunExamples.GetDataDir_Outlook();
            MapiMessage msg     = MapiMessage.FromFile(dataDir + "MsgWithAtt.msg");

            msg.Save(dataDir + "AttachmentsToDestroy_out.msg");

            // ExStart:DestroyAttachment
            MapiMessage.DestroyAttachments(dataDir + "AttachmentsToDestroy_out.msg");
            // ExEnd:DestroyAttachment
        }
Beispiel #15
0
        public static void Run()
        {
            // ExStart:CheckPasswordProtection
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage mapiMessage = MapiMessage.FromFile(dataDir + "message1.msg");

            FollowUpManager.MarkAsCompleted(mapiMessage);
            mapiMessage.Save(dataDir + "MarkedCompleted_out.msg");
        }
Beispiel #16
0
        public static void Run()
        {
            // ExStart:ConvertMIMEMessagesFromMSGToEML
            // The path to the File directory.
            string      dataDir = RunExamples.GetDataDir_Outlook();
            MailMessage msg     = MailMessage.Load(dataDir + "message.eml");
            MapiMessage mapi    = MapiMessage.FromMailMessage(msg, new MapiConversionOptions(OutlookMessageFormat.Unicode));

            // Save File to disk
            mapi.Save(dataDir + "ConvertMIMEMessagesFromMSGToEML_out.msg");
            // ExEnd:ConvertMIMEMessagesFromMSGToEML
        }
Beispiel #17
0
        public static void Run()
        {
            // ExStart:AddVotingButtonToExistingMessage
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage mapi = MapiMessage.FromFile(dataDir + "message.msg");

            FollowUpManager.AddVotingButton(mapi, "Indeed!");
            mapi.Save(dataDir + "AddVotingButtonToExistingMessage_out.msg");
            // ExEnd:AddVotingButtonToExistingMessage
        }
Beispiel #18
0
        public static void Run()
        {
            // ExStart:MarkFollowUpFlagAsCompleted
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage mapiMessage = MapiMessage.FromFile(dataDir + "Message.msg");

            FollowUpManager.MarkAsCompleted(mapiMessage);
            mapiMessage.Save(dataDir + "MarkedCompleted_out.msg");
            // ExEnd:MarkFollowUpFlagAsCompleted
        }
Beispiel #19
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:EmbedMessageAsAttachment
            MapiMessage message   = new MapiMessage("*****@*****.**", "*****@*****.**", "Subj", "This is a message body");
            MapiMessage attachMsg = MapiMessage.FromFile(dataDir + "Message.msg");

            message.Attachments.Add("Weekly report.msg", attachMsg);
            message.Save(dataDir + "WithEmbeddedMsg_out.msg");
            // ExEnd:EmbedMessageAsAttachment
        }
Beispiel #20
0
        public static void Run()
        {
            //ExStart:RemoveFollowUpflag
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Load file from Disk
            MapiMessage mapi = MapiMessage.FromFile(dataDir + "message.msg");

            FollowUpManager.ClearFlag(mapi);
            mapi.Save(dataDir + "RemoveFollowUpflag_out.msg");
            //ExEnd:RemoveFollowUpflag
        }
        public static void Run()
        {
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage msg = CreateTestMessage(false);

            FollowUpOptions options = new FollowUpOptions();

            options.VotingButtons = "Yes;No;Maybe;Exactly!";

            FollowUpManager.SetOptions(msg, options);

            msg.Save(dataDir + "MapiMsgWithPoll.msg");
        }
        public static void Run()
        {
            // ExStart:CreatForwardMessage
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage           originalMsg = MapiMessage.FromFile(dataDir + "message1.msg");
            ForwardMessageBuilder builder     = new ForwardMessageBuilder();

            builder.AdditionMode = OriginalMessageAdditionMode.Textpart;
            MapiMessage forwardMsg = builder.BuildResponse(originalMsg);

            forwardMsg.Save(dataDir + "forward_out.msg");
            // ExStart:CreatForwardMessage
        }
        private void button3_Click(object sender, EventArgs e)
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:AddingMSGAttachments
            // File name for output MSG file
            string strMsgFile;

            // Open a save file dialog for saving the file and Add filter for msg files
            SaveFileDialog fd = new SaveFileDialog();

            fd.Filter = "Outlook Message files (*.msg)|*.msg|All files (*.*)|*.*";

            // If user pressed OK, save the file name + path
            if (fd.ShowDialog() == DialogResult.OK)
            {
                strMsgFile = fd.FileName;
            }
            else
            {
                // If user did not selected the file, return
                return;
            }

            // Create an instance of MailMessage class
            MailMessage mailMsg = new MailMessage();

            // Set from, to, subject and body properties
            mailMsg.From    = txtFrom.Text;
            mailMsg.To      = txtTo.Text;
            mailMsg.Subject = txtSubject.Text;
            mailMsg.Body    = txtBody.Text;

            // Add the attachments
            foreach (string strFileName in lstAttachments.Items)
            {
                mailMsg.Attachments.Add(new Attachment(strFileName));
            }

            // Create an instance of MapiMessage class and pass MailMessage as argument
            MapiMessage outlookMsg = MapiMessage.FromMailMessage(mailMsg);

            outlookMsg.Save(strMsgFile);
            // ExEnd:AddingMSGAttachments
        }
        public static void Run()
        {
            // ExStart:ReadVotingOptionsFromMapiMessage
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create new Message
            MapiMessage msg = CreateTestMessage(false);

            // Set FollowUpOptions Properties
            FollowUpOptions options = new FollowUpOptions();

            options.VotingButtons = "Yes;No;Maybe;Exactly!";

            FollowUpManager.SetOptions(msg, options);
            msg.Save(dataDir + "MapiMsgWithPoll.msg");
            // ExEnd:ReadVotingOptionsFromMapiMessage
        }
Beispiel #25
0
        public static void Run()
        {
            // ExStart:CreatReplyMessage
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage         originalMsg = MapiMessage.FromFile(dataDir + "message1.msg");
            ReplyMessageBuilder builder     = new ReplyMessageBuilder();

            // Set ReplyMessageBuilder Properties
            builder.ReplyAll     = true;
            builder.AdditionMode = OriginalMessageAdditionMode.Textpart;
            builder.ResponseText = "<p><b>Dear Friend,</b></p> I want to do is introduce my co-author and co-teacher. <p><a href=\"www.google.com\">This is a first link</a></p><p><a href=\"www.google.com\">This is a second link</a></p>";

            MapiMessage replyMsg = builder.BuildResponse(originalMsg);

            replyMsg.Save(dataDir + "reply_out.msg");
            // ExEnd:CreatReplyMessage
        }
Beispiel #26
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:CreatingMSGFilesWithRTFBody
            // Create an instance of the MailMessage class
            MailMessage mailMsg = new MailMessage();

            // Set from, to, subject and body properties
            mailMsg.From     = "*****@*****.**";
            mailMsg.To       = "*****@*****.**";
            mailMsg.Subject  = "subject";
            mailMsg.HtmlBody = "<h3>rtf example</h3><p>creating an <b><u>outlook message (msg)</u></b> file using Aspose.Email.</p>";

            MapiMessage outlookMsg = MapiMessage.FromMailMessage(mailMsg);

            outlookMsg.Save(dataDir + "CreatingMSGFilesWithRTFBody_out.msg");
            // ExEnd:CreatingMSGFilesWithRTFBody
        }
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();
            //ExStart: ConvertMapiTaskToMHT
            MapiMessage    msg = MapiMessage.FromFile(dataDir + "MapiTask.msg");
            MhtSaveOptions opt = SaveOptions.DefaultMhtml;

            opt.MhtFormatOptions = MhtFormatOptions.RenderTaskFields | MhtFormatOptions.WriteHeader;

            opt.FormatTemplates.Clear();
            opt.FormatTemplates.Add(MhtTemplateName.Task.Subject, "<span class='headerLineTitle'>Subject:</span><span class='headerLineText'>{0}</span><br/>");
            opt.FormatTemplates.Add(MhtTemplateName.Task.ActualWork, "<span class='headerLineTitle'>Actual Work:</span><span class='headerLineText'>{0}</span><br/>");
            opt.FormatTemplates.Add(MhtTemplateName.Task.TotalWork, "<span class='headerLineTitle'>Total Work:</span><span class='headerLineText'>{0}</span><br/>");
            opt.FormatTemplates.Add(MhtTemplateName.Task.Status, "<span class='headerLineTitle'>Status:</span><span class='headerLineText'>{0}</span><br/>");
            opt.FormatTemplates.Add(MhtTemplateName.Task.Owner, "<span class='headerLineTitle'>Owner:</span><span class='headerLineText'>{0}</span><br/>");
            opt.FormatTemplates.Add(MhtTemplateName.Task.Priority, "<span class='headerLineTitle'>Priority:</span><span class='headerLineText'>{0}</span><br/>");

            msg.Save(dataDir + "MapiTask_out.mht", opt);
            //ExEnd: ConvertMapiTaskToMHT
        }
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:SavingMessageInDraftStatus
            // Change properties of an existing MSG file
            string strExistingMsg = @"message.msg";

            // Load the existing file in MailMessage and Change the properties
            MailMessage msg = MailMessage.Load(dataDir + strExistingMsg, new MsgLoadOptions());

            msg.Subject  += "NEW SUBJECT (updated by Aspose.Email)";
            msg.HtmlBody += "NEW BODY (udpated by Aspose.Email)";

            // Create an instance of type MapiMessage from MailMessage, Set message flag to un-sent (draft status) and Save it
            MapiMessage mapiMsg = MapiMessage.FromMailMessage(msg);

            mapiMsg.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);
            mapiMsg.Save(dataDir + "SavingMessageInDraftStatus_out.msg");
            // ExEnd:SavingMessageInDraftStatus
        }
Beispiel #29
0
        public static void Run()
        {
            // ExStart:SetFollowUpForRecipients
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MailMessage mailMsg = new MailMessage();

            mailMsg.Sender = "*****@*****.**";
            mailMsg.To     = "*****@*****.**";
            mailMsg.Body   = "This message will test if follow up options can be added to a new mapi message.";

            MapiMessage mapi = MapiMessage.FromMailMessage(mailMsg);

            mapi.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT);  // Mark this message as draft

            DateTime dtReminderDate = new DateTime(2013, 5, 23, 16, 40, 0);

            // Add the follow up flag for receipient now
            FollowUpManager.SetFlagForRecipients(mapi, "Follow up", dtReminderDate);
            mapi.Save(dataDir + "SetFollowUpForRecipients_out.msg");
            // ExEnd:SetFollowUpForRecipients
        }
        public static void Run()
        {
            // ExStart:RemovePropertiesFromMSGAndAttachments
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage mapi = new MapiMessage("*****@*****.**", "*****@*****.**", "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
        }
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:CreatingAndSavingOutlookMessages
            // Create an instance of the MailMessage class
            MailMessage mailMsg = new MailMessage();

            // Set from, to, subject and body properties
            mailMsg.From    = "*****@*****.**";
            mailMsg.To      = "*****@*****.**";
            mailMsg.Subject = "This is test message";
            mailMsg.Body    = "This is test body";

            // Create an instance of the MapiMessage class and pass MailMessage as argument
            MapiMessage outlookMsg = MapiMessage.FromMailMessage(mailMsg);

            // Save the message (MSG) file
            string strMsgFile = @"CreatingAndSavingOutlookMessages_out.msg";

            outlookMsg.Save(dataDir + strMsgFile);
            // ExEnd:CreatingAndSavingOutlookMessages
        }
        public static void Run()
        {
            // ExStart:RemovePropertiesFromMSGAndAttachments
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage mapi = new MapiMessage("*****@*****.**", "*****@*****.**", "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
        }