none
System.Runtime.InteropServices.COMException (0x80004004): Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) at Microsoft.Office.Interop.Outlook._MailItem.Send() Exception RRS feed

  • Question

  • I am using the below code to send Email through the outlook. But it throws  "System.Runtime.InteropServices.COMException (0x80004004): Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) at Microsoft.Office.Interop.Outlook._MailItem.Send() at ExcelAutomate2.Form1.sendEMailThroughOUTLOOK() " Exception

    It is opening the outlook instance and creating the email but Email is not being sent and above exception occurs.

    Please help me to solve this.

                    

    try
                {

    Outlook.Application app = new Outlook.Application();
                    Outlook.MailItem mailItem = app.CreateItem(Outlook.OlItemType.olMailItem);
                    mailItem.Subject = "This is the subject";
                    mailItem.To = "Priyanka.Dudalkar@in.ey.com";
                    mailItem.Body = "This is the message.";

                    mailItem.Importance = Outlook.OlImportance.olImportanceHigh;
                    mailItem.Display(false);
                    ((Outlook._MailItem)mailItem).Send();

            }

                    



                


    • Edited by PriyankaTD Thursday, April 19, 2018 1:05 PM
    • Moved by CoolDadTx Thursday, April 19, 2018 2:57 PM Office related
    Thursday, April 19, 2018 12:57 PM

All replies

  • Hi PriyankaTD,

    I try to make a test on my side and find that your code is working fine on my side.

    There is no any error.

    It looks like you are using Outlook 64 bit version.

    But your setting of platform target is set for any cpu.

    It is possible that this can cause the error.

    So if you are using 64 bit Outlook then go to Properties of your project .

    Select platform target to X64 as you can see in image below.

    It can solve your issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 20, 2018 5:55 AM
    Moderator
  • Thanks Deepak for replying.

    I tried with the solution you mentioned. But still it is throwing same exception.

    Saturday, April 21, 2018 1:16 PM
  • Hello Priyanka,

    Most probably you have faced with a security issue in Outlook. "Security" in this context refers to the so-called "object model guard" that triggers security prompts and blocks access to certain features in an effort to prevent malicious programs from harvesting email addresses from Outlook data and using Outlook to propagate viruses and spam. These prompts cannot simply be turned off, except in Outlook 2007 with an anti-virus application running.

    The Outlook "Object Model Guard" Security Issues for Developers page discusses strategies for avoiding the security prompts:

    1. A low-level API on which Outlook is based on - Extended MAPI (or any other third-party wrappers around that API, for example, Redemption).

    2. Outlook Security Manager is a programming tool that allows you to suppress security alerts invoked by the code of your application or add-in that interacts with Microsoft Outlook 2000 - 2013.

    3. In a corporate environment, the administrator may choose to loosen Outlook security for some or all users.

    4. Develop a trusted COM add-in and call it for sending emails instead of using OOM directly.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, April 23, 2018 8:40 AM