2016-06-08 52 views
1

我坚持这一点。这是我的示例代码。 我想创建一个邮件项目并将其从数据库绑定为邮件消息。 然后我想用outlook的回复模式回复它。从:,加到:,那条水平线等等。上述theoriginal邮件.. 但它不是对‘为的MailItem Globals.ThisAddIn.Application.CreateItem(OlItemType.olMailItem)’MailItem.Reply()与新创建MailItem给出“无法发送邮件”错误

MailItem.Reply(如创建的邮件的工作)是完全工作时,是的MailItem之一Globals.ThisAddIn.Application.ActiveExplorer()。选择项目 我在这里失踪了什么?

感谢..

  MailItem oItem = Globals.ThisAddIn.Application.CreateItem(OlItemType.olMailItem) as MailItem; 
      oItem.Body = "..."; 
      oItem.To = "[email protected]"; 
      oItem.CC = "[email protected]"; 
      oItem.Subject = "...."; 
      MailItem response = oItem.Reply(); 

错误代码这里: 'System.Runtime.InteropServices.COMException' 类型的异常出现在HMOutlookAddIn.dll但在用户代码中没有处理

更多信息:无法发送邮件。

错误代码:-2147352567

回答

0

没有必要回复新创建的项目。 Reply方法只能用于收到的邮件。

相反,您需要使用MailItem类的Send方法。

mail = OutlookApp.CreateItem(Outlook.OlItemType.olMailItem) 
     as Outlook.MailItem; 
    mail.Subject = "A programatically generated e-mail"; 
    mailRecipients = mail.Recipients; 
    mailRecipient = mailRecipients.Add("Eugene Astafiev"); 
    mailRecipient.Resolve(); 
    if (mailRecipient.Resolved) 
    { 
     mail.Send(); 
    } 
    else 
    { 
     System.Windows.Forms.MessageBox.Show(
      "There is no such record in your address book."); 
    } 

您可能会发现下面的文章有帮助:

相关问题