Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:38:29+00:00 2026-06-02T19:38:29+00:00

I created a small C# console app to send mails using outlook which is

  • 0

I created a small C# console app to send mails using outlook which is very simple

Outlook.Application oApp = new Outlook.Application();
            //Create the new message by using the simplest approach.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
            oMsg.Recipients.Add("xxx@xxx.com");  //////////////////problem line 
            oMsg.Subject = "aaaa";
            oMsg.Body = "body";
            //Send the message.
            oMsg.Save();
            oMsg.Send();

This code needs to be invoked from php code .

1) It works in console just fine .

2) when i invoke from php i get a error . I noticed that this console app when called from php would run in system user. so i made outlook to run as system but i still get this error. i am running Apache server .

System.Runtime.InteropServices.COMException (0x80004004): Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
at Microsoft.Office.Interop.Outlook._MailItem.get_Recipients()
at SyncEmail.Program.sendMailUsingOutlook(String recipient, String body, String subject) in D:\NotEncrypted\Projects\SyncEmail\SyncEmail\Program.cs:line 121

I am pulling my hair out looking at different things . Any help would be appreciated. Thanks for reading my post .

After i say some guys say use php i decided to go php route and wrote this code and get the same error .

if (!defined(‘olMailItem’)) define(“olMailItem”,0);
$objApp = new COM(“Outlook.Application”);
$myItem = $objApp->CreateItem(olMailItem);
$myItem->To=’xxxx@xxx.com’;
$myItem->SentOnBehalfOfName = ‘yyy@xxyyx.com’;
$myItem->Subject=”This is a test”;
$myItem->Body=”This is a Body Section now…..!”;
$myItem->Send();

i get this error

Fatal error: Uncaught exception ‘com_exception’ with message ‘ in D:\NotEncrypted\xampp\htdocs\copper\system\modules\projects\index.php on line 11251
( ! ) com_exception: Error [0x80004004] Operation aborted in D:\NotEncrypted\xampp\htdocs\copper\system\modules\projects\index.php on line 11251

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:38:31+00:00Added an answer on June 2, 2026 at 7:38 pm

    PHP can get the JOB done directly

    $oApp  = new COM("Outlook.Application") or die('error');
    $oMsg  = $oApp ->CreateItem($oApp->OlItemTyp->olMailItem);
    $oMsg ->Recipients->Add("xxx@xxx.com");
    $oMsg ->Subject="aaaa";
    $oMsg ->Body="body";
    $oMsg ->Save();
    $oMsg ->Send();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My intend is to create a simple easily debuggable console application which will be
I have created a small chatting application in C#, and started as a Console
I have created a small and simple android app. I tried installing it on
I'm attempting to create a small console app in C# to perform inserts on
I'm looking to create a very small cataloguing app for personal use (although I'd
I have simple console application project for live video streaming using cross-platform libs on
I have created a small WIN32 Console Application in Visual C++ in Windows 7.
I've created a small console application to see how quartz work and it was
I have created a small daemon (basically a console application that hides the console
I created a small vb.net console app in visual studio 2008 trying to learn

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.