c# winforms: button to open outlook inbox page (outlook saved in computer)












0














I intend to open an outlook inbox page (see image) when the button is clicked. I use the code below but nothing happened. Hope to get some help



    private void button6_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); ;
Microsoft.Office.Interop.Outlook.AppointmentItem appointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
}


enter image description here










share|improve this question



























    0














    I intend to open an outlook inbox page (see image) when the button is clicked. I use the code below but nothing happened. Hope to get some help



        private void button6_Click(object sender, EventArgs e)
    {
    Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); ;
    Microsoft.Office.Interop.Outlook.AppointmentItem appointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
    }


    enter image description here










    share|improve this question

























      0












      0








      0







      I intend to open an outlook inbox page (see image) when the button is clicked. I use the code below but nothing happened. Hope to get some help



          private void button6_Click(object sender, EventArgs e)
      {
      Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); ;
      Microsoft.Office.Interop.Outlook.AppointmentItem appointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
      }


      enter image description here










      share|improve this question













      I intend to open an outlook inbox page (see image) when the button is clicked. I use the code below but nothing happened. Hope to get some help



          private void button6_Click(object sender, EventArgs e)
      {
      Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); ;
      Microsoft.Office.Interop.Outlook.AppointmentItem appointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
      }


      enter image description here







      outlook






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 21:03









      masyita shariff

      336




      336
























          3 Answers
          3






          active

          oldest

          votes


















          1














          I managed to solve my own question. I didn't state in my original question but outlook app is already downloaded inside my laptop.



          private void button6_Click(object sender, EventArgs e)
          {
          Process.Start("outlook.exe");
          }


          Thanks to all of yall suggestions






          share|improve this answer





























            0














            I checked your code without an problem. So you need to track your error message of WindowsForm APP and confirm closed your Outlook. In general, you may getting the error about COM ID issue.



            Please refer to the following links:



            How to open Outlook new mail window c#



            Code:



            Outlook.Application oApp    = new Outlook.Application ();
            Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem ( Outlook.OlItemType.olMailItem );
            oMailItem.To = address;
            // body, bcc etc...
            oMailItem.Display ( true );


            Debug Error:



            new Outlook.Application() thorws error if Outlook app is running






            share|improve this answer





















            • Hi Simon, I've checked the link above and followed the dcomcnfg thingy and I cannot find outlook message attachment, so maybe not a COM problem? Aactually my code above, once I pressed the button, there will be a pop-up at my taskbar stating: Another program is using outlook. To disconnect program and exit outlook, click outlook icon and click exit now. In reality, I did not open and outlook and when I checked control panel, outlook is also not running.
              – masyita shariff
              Nov 23 at 6:17










            • Maybe some programs are using your Outlook, I think you need to check it.
              – Simon Li
              Nov 27 at 7:08



















            0














            Try something like the following (off the top of my head):



            Outlook.Application oApp    = new Outlook.Application ();
            Outlook.Namespace ns = oApp.GetNamespace("MAPI");
            ns.Logon();
            Outlook.MAPIFolder inbox = ns.GetDEfaultFolder(olFolderInbox);
            if (oApp.Explorers.Count > 0)
            {
            Outlook.Explorer expl = oApp.Explorers[1];
            expl.CurrentFolder = inbox;
            }
            else
            {
            inbox.Display();
            }





            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437954%2fc-sharp-winforms-button-to-open-outlook-inbox-page-outlook-saved-in-computer%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              I managed to solve my own question. I didn't state in my original question but outlook app is already downloaded inside my laptop.



              private void button6_Click(object sender, EventArgs e)
              {
              Process.Start("outlook.exe");
              }


              Thanks to all of yall suggestions






              share|improve this answer


























                1














                I managed to solve my own question. I didn't state in my original question but outlook app is already downloaded inside my laptop.



                private void button6_Click(object sender, EventArgs e)
                {
                Process.Start("outlook.exe");
                }


                Thanks to all of yall suggestions






                share|improve this answer
























                  1












                  1








                  1






                  I managed to solve my own question. I didn't state in my original question but outlook app is already downloaded inside my laptop.



                  private void button6_Click(object sender, EventArgs e)
                  {
                  Process.Start("outlook.exe");
                  }


                  Thanks to all of yall suggestions






                  share|improve this answer












                  I managed to solve my own question. I didn't state in my original question but outlook app is already downloaded inside my laptop.



                  private void button6_Click(object sender, EventArgs e)
                  {
                  Process.Start("outlook.exe");
                  }


                  Thanks to all of yall suggestions







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 3 at 9:34









                  masyita shariff

                  336




                  336

























                      0














                      I checked your code without an problem. So you need to track your error message of WindowsForm APP and confirm closed your Outlook. In general, you may getting the error about COM ID issue.



                      Please refer to the following links:



                      How to open Outlook new mail window c#



                      Code:



                      Outlook.Application oApp    = new Outlook.Application ();
                      Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem ( Outlook.OlItemType.olMailItem );
                      oMailItem.To = address;
                      // body, bcc etc...
                      oMailItem.Display ( true );


                      Debug Error:



                      new Outlook.Application() thorws error if Outlook app is running






                      share|improve this answer





















                      • Hi Simon, I've checked the link above and followed the dcomcnfg thingy and I cannot find outlook message attachment, so maybe not a COM problem? Aactually my code above, once I pressed the button, there will be a pop-up at my taskbar stating: Another program is using outlook. To disconnect program and exit outlook, click outlook icon and click exit now. In reality, I did not open and outlook and when I checked control panel, outlook is also not running.
                        – masyita shariff
                        Nov 23 at 6:17










                      • Maybe some programs are using your Outlook, I think you need to check it.
                        – Simon Li
                        Nov 27 at 7:08
















                      0














                      I checked your code without an problem. So you need to track your error message of WindowsForm APP and confirm closed your Outlook. In general, you may getting the error about COM ID issue.



                      Please refer to the following links:



                      How to open Outlook new mail window c#



                      Code:



                      Outlook.Application oApp    = new Outlook.Application ();
                      Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem ( Outlook.OlItemType.olMailItem );
                      oMailItem.To = address;
                      // body, bcc etc...
                      oMailItem.Display ( true );


                      Debug Error:



                      new Outlook.Application() thorws error if Outlook app is running






                      share|improve this answer





















                      • Hi Simon, I've checked the link above and followed the dcomcnfg thingy and I cannot find outlook message attachment, so maybe not a COM problem? Aactually my code above, once I pressed the button, there will be a pop-up at my taskbar stating: Another program is using outlook. To disconnect program and exit outlook, click outlook icon and click exit now. In reality, I did not open and outlook and when I checked control panel, outlook is also not running.
                        – masyita shariff
                        Nov 23 at 6:17










                      • Maybe some programs are using your Outlook, I think you need to check it.
                        – Simon Li
                        Nov 27 at 7:08














                      0












                      0








                      0






                      I checked your code without an problem. So you need to track your error message of WindowsForm APP and confirm closed your Outlook. In general, you may getting the error about COM ID issue.



                      Please refer to the following links:



                      How to open Outlook new mail window c#



                      Code:



                      Outlook.Application oApp    = new Outlook.Application ();
                      Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem ( Outlook.OlItemType.olMailItem );
                      oMailItem.To = address;
                      // body, bcc etc...
                      oMailItem.Display ( true );


                      Debug Error:



                      new Outlook.Application() thorws error if Outlook app is running






                      share|improve this answer












                      I checked your code without an problem. So you need to track your error message of WindowsForm APP and confirm closed your Outlook. In general, you may getting the error about COM ID issue.



                      Please refer to the following links:



                      How to open Outlook new mail window c#



                      Code:



                      Outlook.Application oApp    = new Outlook.Application ();
                      Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem ( Outlook.OlItemType.olMailItem );
                      oMailItem.To = address;
                      // body, bcc etc...
                      oMailItem.Display ( true );


                      Debug Error:



                      new Outlook.Application() thorws error if Outlook app is running







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 23 at 1:46









                      Simon Li

                      23014




                      23014












                      • Hi Simon, I've checked the link above and followed the dcomcnfg thingy and I cannot find outlook message attachment, so maybe not a COM problem? Aactually my code above, once I pressed the button, there will be a pop-up at my taskbar stating: Another program is using outlook. To disconnect program and exit outlook, click outlook icon and click exit now. In reality, I did not open and outlook and when I checked control panel, outlook is also not running.
                        – masyita shariff
                        Nov 23 at 6:17










                      • Maybe some programs are using your Outlook, I think you need to check it.
                        – Simon Li
                        Nov 27 at 7:08


















                      • Hi Simon, I've checked the link above and followed the dcomcnfg thingy and I cannot find outlook message attachment, so maybe not a COM problem? Aactually my code above, once I pressed the button, there will be a pop-up at my taskbar stating: Another program is using outlook. To disconnect program and exit outlook, click outlook icon and click exit now. In reality, I did not open and outlook and when I checked control panel, outlook is also not running.
                        – masyita shariff
                        Nov 23 at 6:17










                      • Maybe some programs are using your Outlook, I think you need to check it.
                        – Simon Li
                        Nov 27 at 7:08
















                      Hi Simon, I've checked the link above and followed the dcomcnfg thingy and I cannot find outlook message attachment, so maybe not a COM problem? Aactually my code above, once I pressed the button, there will be a pop-up at my taskbar stating: Another program is using outlook. To disconnect program and exit outlook, click outlook icon and click exit now. In reality, I did not open and outlook and when I checked control panel, outlook is also not running.
                      – masyita shariff
                      Nov 23 at 6:17




                      Hi Simon, I've checked the link above and followed the dcomcnfg thingy and I cannot find outlook message attachment, so maybe not a COM problem? Aactually my code above, once I pressed the button, there will be a pop-up at my taskbar stating: Another program is using outlook. To disconnect program and exit outlook, click outlook icon and click exit now. In reality, I did not open and outlook and when I checked control panel, outlook is also not running.
                      – masyita shariff
                      Nov 23 at 6:17












                      Maybe some programs are using your Outlook, I think you need to check it.
                      – Simon Li
                      Nov 27 at 7:08




                      Maybe some programs are using your Outlook, I think you need to check it.
                      – Simon Li
                      Nov 27 at 7:08











                      0














                      Try something like the following (off the top of my head):



                      Outlook.Application oApp    = new Outlook.Application ();
                      Outlook.Namespace ns = oApp.GetNamespace("MAPI");
                      ns.Logon();
                      Outlook.MAPIFolder inbox = ns.GetDEfaultFolder(olFolderInbox);
                      if (oApp.Explorers.Count > 0)
                      {
                      Outlook.Explorer expl = oApp.Explorers[1];
                      expl.CurrentFolder = inbox;
                      }
                      else
                      {
                      inbox.Display();
                      }





                      share|improve this answer


























                        0














                        Try something like the following (off the top of my head):



                        Outlook.Application oApp    = new Outlook.Application ();
                        Outlook.Namespace ns = oApp.GetNamespace("MAPI");
                        ns.Logon();
                        Outlook.MAPIFolder inbox = ns.GetDEfaultFolder(olFolderInbox);
                        if (oApp.Explorers.Count > 0)
                        {
                        Outlook.Explorer expl = oApp.Explorers[1];
                        expl.CurrentFolder = inbox;
                        }
                        else
                        {
                        inbox.Display();
                        }





                        share|improve this answer
























                          0












                          0








                          0






                          Try something like the following (off the top of my head):



                          Outlook.Application oApp    = new Outlook.Application ();
                          Outlook.Namespace ns = oApp.GetNamespace("MAPI");
                          ns.Logon();
                          Outlook.MAPIFolder inbox = ns.GetDEfaultFolder(olFolderInbox);
                          if (oApp.Explorers.Count > 0)
                          {
                          Outlook.Explorer expl = oApp.Explorers[1];
                          expl.CurrentFolder = inbox;
                          }
                          else
                          {
                          inbox.Display();
                          }





                          share|improve this answer












                          Try something like the following (off the top of my head):



                          Outlook.Application oApp    = new Outlook.Application ();
                          Outlook.Namespace ns = oApp.GetNamespace("MAPI");
                          ns.Logon();
                          Outlook.MAPIFolder inbox = ns.GetDEfaultFolder(olFolderInbox);
                          if (oApp.Explorers.Count > 0)
                          {
                          Outlook.Explorer expl = oApp.Explorers[1];
                          expl.CurrentFolder = inbox;
                          }
                          else
                          {
                          inbox.Display();
                          }






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 23 at 3:06









                          Dmitry Streblechenko

                          42.3k32760




                          42.3k32760






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437954%2fc-sharp-winforms-button-to-open-outlook-inbox-page-outlook-saved-in-computer%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              What visual should I use to simply compare current year value vs last year in Power BI desktop

                              Alexandru Averescu

                              Trompette piccolo