下面的代码片段在行
时为我提供了“COMException
”
>mail.SaveAs(@"C:\Users\Michalczak\Desktop");
。 事件被正确触发并触发事件处理程序。
>InboxFolder_ItemAdd(object o)
异常 - 在catch块中抛出的消息类似于:
> You do not have permission to perform this operation.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
myTestInBox = (Outlook.Folder)this.Application.Session.GetDefaultFolder
(Outlook.OlDefaultFolders.olFolderInbox);
stor.inBox = myTestInBox.Items;
stor.inBox.ItemAdd +=
new Outlook.ItemsEvents_ItemAddEventHandler
(InboxFolder_ItemAdd);
}
private void InboxFolder_ItemAdd(object o)
{
Outlook.MailItem mail = null;
if ( o != null && o is Outlook.MailItem)
{
mail = (Outlook.MailItem)o;
}
try
{
mail.SaveAs(@"C:\Users\Michalczak\Desktop");
}
catch (System.Runtime.InteropServices.COMException ce)
{
MessageBox.Show(ce.Source);
MessageBox.Show(ce.Message);
}
}
答案 0 :(得分:0)
SaveAs需要带有文件名的完整路径:
exec.Command("sh", "-c", "echo '1 2 3'")