Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用outlook 2013和C编写电子邮件#_C#_Outlook - Fatal编程技术网

C# 使用outlook 2013和C编写电子邮件#

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

我正在尝试使用c#撰写和发送电子邮件,并打开outlook 2013的撰写窗口。下面是我的代码。它不会显示任何错误,但不会打开任何窗口!是否有人知道可能出现的问题:

                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;

是的,我确实试过了,但在我的系统上不起作用,因为它有问题,需要重新启动。非常感谢。