public void EnterMessageText(string text) { MessageBody.Clear(); MessageBody.SendKeys(text); }
private void ShowMessage(LocalMail message) { if (message == null) { SetHeader(""); MessageBody.Clear(); return; } string content = "<b><font size=2>" + message.Info.Subject + "</font></b> from " + Core.GetName(message.Header.SourceID) + ", sent " + Utilities.FormatTime(message.Info.Date) + @"<br> <b>To:</b> " + Mail.GetNames(message.To) + "<br>"; if (message.CC.Count > 0) { content += "<b>CC:</b> " + Mail.GetNames(message.CC) + "<br>"; } if (message.Attached.Count > 1) { string attachHtml = ""; for (int i = 0; i < message.Attached.Count; i++) { if (message.Attached[i].Name == "body") { continue; } attachHtml += "<a href='http://attach/" + i.ToString() + "'>" + message.Attached[i].Name + "</a> (" + Utilities.ByteSizetoString(message.Attached[i].Size) + "), "; } attachHtml = attachHtml.TrimEnd(new char[] { ' ', ',' }); content += "<b>Attachments: </b> " + attachHtml; } content += "<br>"; string actions = ""; if (message.Header.TargetID == Core.UserID) { actions += @"<a href='http://reply" + "'>Reply</a>"; } actions += @", <a href='http://forward'>Forward</a>"; actions += @", <a href='http://delete'>Delete</a>"; content += "<b>Actions: </b>" + actions.Trim(',', ' '); SetHeader(content); // body try { using (TaggedStream stream = new TaggedStream(Mail.GetLocalPath(message.Header), Core.GuiProtocol)) using (CryptoStream crypto = IVCryptoStream.Load(stream, message.Header.LocalKey)) { int buffSize = 4096; byte[] buffer = new byte[4096]; long bytesLeft = message.Header.FileStart; while (bytesLeft > 0) { int readSize = (bytesLeft > buffSize) ? buffSize : (int)bytesLeft; int read = crypto.Read(buffer, 0, readSize); bytesLeft -= read; } // load file foreach (MailFile file in message.Attached) { if (file.Name == "body") { byte[] msgBytes = new byte[file.Size]; crypto.Read(msgBytes, 0, (int)file.Size); UTF8Encoding utf = new UTF8Encoding(); MessageBody.Clear(); MessageBody.SelectionFont = new Font("Tahoma", 9.75f); MessageBody.SelectionColor = Color.Black; if (message.Info.Format == TextFormat.RTF) { MessageBody.Rtf = utf.GetString(msgBytes); } else { MessageBody.Text = utf.GetString(msgBytes); } MessageBody.DetectLinksDefault(); } } } } catch (Exception ex) { MessageBox.Show(this, "Error Opening Mail: " + ex.Message); } if (message.Header.Read == false) { message.Header.Read = true; Mail.SaveMailbox = true; if (MessageView.SelectedNodes.Count > 0) { ((MessageNode)MessageView.SelectedNodes[0]).UpdateRow(); } } }