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 7092793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:21:31+00:00 2026-05-28T08:21:31+00:00

My application has a requirement to open the send email window in outlook. The

  • 0

My application has a requirement to open the send email window in outlook.

The application displays a list of invoices. When the user clicks on an invoice number I need to open the send email window in outlook and attach the PDF statement. The user can then modify the message and click send.

How can I accomplish this?

I have tried the following:

    using Outlook = Microsoft.Office.Interop.Outlook;

The application works fine on development environment but iam getting an exception:

**System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))**

Detailed:

    System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
     at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at InvoiceSearchTool.Controllers.emailController.CreateMessageWithAttachment(String invoiceNumber, String recipient, String messageBody) in C:\Projects\KeleInvoice\InvoiceSearchTool\Controllers\emailController.cs:line 38

I do not have outlook installed on application server. do i need to istall outlook on server? or the exception is for some other reason? how to get rid of it?

EDIT: Adding Code

public static void CreateMessageWithAttachment(string invoiceNumber, string recipient, string messageBody )
    {
        try
        {

            Outlook.Application oApp = new Outlook.Application();
            Outlook.MailItem email = (Outlook.MailItem)(oApp.CreateItem(Outlook.OlItemType.olMailItem));

            Models.DYNAMICS_EXTEntities _db = new Models.DYNAMICS_EXTEntities();

            #region set email recipients
            {
                ObjectParameter[] parameters = new ObjectParameter[1];
                parameters[0] = new ObjectParameter("InvoiceNumber", invoiceNumber);

                List<Models.EmailAddress> emailList = _db.ExecuteFunction<Models.EmailAddress>("uspGetEmailAddress", parameters).ToList<Models.EmailAddress>();
                if (emailList.Count() > 0)
                {
                    if(!(string.IsNullOrEmpty(emailList[0].Email.ToString().Trim()) ))
                    recipient = emailList[0].Email.ToString().Trim();
                    else
                        recipient = " ";
                }
                else
                    recipient = " ";

                email.Recipients.Add(recipient);
            }
            #endregion

            //email subject                 
            email.Subject = "Invoice # " + invoiceNumber;

            #region set email Text
            {
                Models.EmailText emailText = _db.ExecuteFunction<Models.EmailText>("uspEmailText").SingleOrDefault();

                messageBody = emailText.EmailTextLine1.ToString().Trim();
                email.Body = messageBody;
            }
            #endregion

            #region email attachment
            {
                string fileName = invoiceNumber.Trim();
                string filePath = HostingEnvironment.MapPath("~/Content/reports/");
                filePath = filePath + fileName + ".pdf";
                fileName += ".pdf";
                int iPosition = (int)email.Body.Length + 1;
                int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
                Outlook.Attachment oAttach = email.Attachments.Add(filePath, iAttachType, iPosition, fileName);
            }
            #endregion

            email.Display();                

                        }
        catch (Exception e)
        {
            InvoiceSearchTool.Models.udtExceptionTable exception = new udtExceptionTable();
            exception.MethodName = "email";
            exception.Exception = e.ToString();
            exception.Date = DateTime.Now;
            DYNAMICS_EXTEntities db = new DYNAMICS_EXTEntities();
            db.AddToudtExceptionTables(exception);
            db.SaveChanges();

        }

    }
  • 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-05-28T08:21:32+00:00Added an answer on May 28, 2026 at 8:21 am

    Now that we have your actual requirements, things get a little easier.

    First off, get rid of Outlook from the mix. You don’t need it.

    When the user clicks the invoice number, ask them for the message to go along with the email. Once they type this in use the standard .net smtp objects to create the mail message, attach the pdf and send through your mail server.

    You don’t need Outlook installed on the server, nor do you need any type of interop.

    If you are using Exchange or an IMAP server then the email will show up in the users outlook Sent box for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems like a standard requirement: next time the user launches the application, open
I have an application which has the requirement, but infrequent usage, of uploading an
Am working on an application which has a requirement to download bulk data from
My application has a requirement that we need to encrypt index fields. Right now
I have a web application that has a requirement to take data from an
I have a requirement to create an application that will open up about 10
My application has a following requirement. 1) First screen has two tabs. 2) From
We need to send email from our desktop application using C# 3.5 . The
Our application has a service layer and a DAO layer, written as Spring beans.
Our application has many controls that are created dynamically. For example, a navigation pane

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.