C# 使用outlook 2013和C编写电子邮件#
我正在尝试使用c#撰写和发送电子邮件,并打开outlook 2013的撰写窗口。下面是我的代码。它不会显示任何错误,但不会打开任何窗口!是否有人知道可能出现的问题:C# 使用outlook 2013和C编写电子邮件#,c#,outlook,C#,Outlook,我正在尝试使用c#撰写和发送电子邮件,并打开outlook 2013的撰写窗口。下面是我的代码。它不会显示任何错误,但不会打开任何窗口!是否有人知道可能出现的问题: Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
mailItem.To = "someone@example.com";
mailItem.Body = "This is the message.";
//mailItem.Attachments.Add(logPath);//logPath is a string holding path to the log.txt file
mailItem.Display(false);
您非常接近,只需设置
mailItem.Display(true)
以下内容对我有效:
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
mailItem.To = "someone@example.com";
mailItem.Body = "This is the message.";
//mailItem.Attachments.Add(logPath);//logPath is a string holding path to the log.txt file
mailItem.Display(true) //THIS IS THE CHANGE;
是的,我确实试过了,但在我的系统上不起作用,因为它有问题,需要重新启动。非常感谢。