我想知道,我怎樣才能將創建的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