Sending Email through Outlook 2010 via C#

前端 未结 3 1167
广开言路
广开言路 2020-12-05 05:31

I am trying to send an email from inside my C# console App. I have added the references and using statements but it seems I have not added everything I need. This is the f

3条回答
  •  旧时难觅i
    2020-12-05 05:32

    replace the line

    Outlook.MailItem mailItem = (Outlook.MailItem)
    this.Application.CreateItem(Outlook.OlItemType.olMailItem);
    

    with

    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);
    

    Hope this helps,

提交回复
热议问题