private void button3_Click(object sender, EventArgs e) { string textmessage = ""; foreach(ListViewItem lvi in this.listView1.Items){ OutlookStorage.Message outlookMsg = new OutlookStorage.Message(lvi.Text); //Console.WriteLine("Subject: {0}", outlookMsg.Subject); //Console.WriteLine("Body: {0}", outlookMsg.BodyText); textmessage += outlookMsg.BodyText; } this.outputText.Text = textmessage; using (System.IO.StreamWriter file = new System.IO.StreamWriter("output.txt", true)) { file.Write(textmessage); } }
// Email public static int storeEmail(int collectionId, int userId, int classId, string emailName) { Stream messageStream = File.Open(emailName, FileMode.Open, FileAccess.Read); OutlookStorage.Message message = new OutlookStorage.Message(messageStream); messageStream.Close(); int id = insertEmail( emailName, collectionId, userId, classId, message.ReceivedOrSentTime.ToString(), message.Subject, message.BodyText ); storeEmailParticipant(id, message.FromAddress, "From"); foreach (string p in parseAddresses(message.Recipients, OutlookStorage.RecipientType.To)) storeEmailParticipant(id, p, "To"); foreach (string p in parseAddresses(message.Recipients, OutlookStorage.RecipientType.CC)) storeEmailParticipant(id, p, "Cc"); return id; }
/// <summary> /// Load an individual email /// </summary> /// <param name="path"></param> private void LoadMessage(string path) { // open a message stream to get the message object Stream messageStream = File.Open(path, FileMode.Open, FileAccess.Read); OutlookStorage.Message message = new OutlookStorage.Message(messageStream); messageStream.Close(); // set the basic properties body.Rtf = message.BodyRTF; subject.Text = message.Subject; from.Text = string.Format("{0} <{1}>", message.From, message.GetMapiPropertyString("5D01")); headers.Text = message.GetMapiPropertyString("007D"); // add the recipients AddRecipients(message); // add any attachments AddAttachments(message); // populate the extended data PopulateData(message); }