我想知道,我怎样才能将创建的PDF文件与Windows窗体数据附加到新的Outlook电子邮件消息中。用下面的代码创建PDF。我可以在同其他括号写:C#创建附带创建的PDF文件的Outlook消息
else {
CreatePDF();
//This is an example EmailMessage();
}
private void EmailMessage()
{
try
{
Outlook.MailItem mailItem = (Outlook.MailItem)
this.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
mailItem.To = "[email protected]";
mailItem.Body = "This is the message.";
mailItem.Importance = Outlook.OlImportance.olImportanceLow;
mailItem.Display(false);
}
catch (Exception eX)
{
throw new Exception("cDocument: Error occurred trying to Create an Outlook Email"
+ Environment.NewLine + eX.Message);
}
}
public void CreatePdf()
{
try
{
string imageFile = "";
System.Drawing.Rectangle bounds = this.Bounds;
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
//pictureBox1.Image();
}
//==================add firstname
if (textBox1.Text != null && textBox1.Text.Trim() != "")
{ imageFile = "C:/Users/Marc/Desktop/" + DateTime.Now.ToString("dddd dd MMMM hh-mm-ss tt") + textBox1.Text; }
else
{ imageFile = "C:/Users/Marc/Desktop/" + DateTime.Now.ToString("dddd dd MMMM hh-mm-ss tt") + "Rectangle"; }
bitmap.Save(imageFile + ".bmp", ImageFormat.Bmp);
formToImage(imageFile);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message.ToString());
}
}`
CreatePDF的输出是什么?它是文件系统中的文件吗?或内存中的一个字节[]? –
你正在创建什么类型的应用程序?一个Outlook插件或一个独立的应用程序? –
一个独立的Windows C#应用程序开发与视觉工作室2015. – NinjaCoder