我想将富文本框保存为 pdf 文件。每次我保存文件时,Adobe Reader 都无法打开它。
private void button3_Click(object sender, EventArgs e)
{
SaveFileDialog MyFiles = new SaveFileDialog();
MyFiles.Filter = "PDF Files|*.pdf";
MyFiles.Title = "Save As...";
MyFiles.DefaultExt = "*.pdf";
if (MyFiles.ShowDialog() == DialogResult.OK)
{
richTextBox1.SaveFile(MyFiles.FileName, RichTextBoxStreamType.PlainText);
richTextBox3.SaveFile(MyFiles.FileName, RichTextBoxStreamType.PlainText);
richTextBox4.SaveFile(MyFiles.FileName, RichTextBoxStreamType.PlainText);
richTextBox5.SaveFile(MyFiles.FileName, RichTextBoxStreamType.PlainText);
}
}
我还制作了发送按钮来发送带有附件的电子邮件,但问题是我无法发送电子邮件:
MailMessage MyMail = new MailMessage(richTextBox1.Text, richTextBox4.Text);
MyMail.To.Add(new MailAddress(richTextBox4.Text));
MailAddress mail = new MailAddress(richTextBox1.Text);
MyMail.From = mail;
MyMail.Subject = richTextBox5.Text;
MyMail.Body = richTextBox3.Text;
MyMail.Attachments.Add(new Attachment(richTextBox2.Text));
SmtpClient MySmtp = new SmtpClient(TheServer.Text);
MySmtp.UseDefaultCredentials = true;
MySmtp.EnableSsl = true;
MySmtp.Port = Convert.ToInt32(ThePort.Text);
MySmtp.Send(MyMail);