title: Problem making appear the custom ribbon - Outlook 365
body: <p>I need your help. I am new creating VSTOs. This code works and it creates my XML, such as I want it. However, the ribbon and the button do not get to show in my outlook. I am using OUTLOOK 365 ProPlus</p>
  
  <p>My Idea is when the user clicks the custom button which is located on the custom ribbon; the email selected got save into an XML file. "This is my goal"</p>
  
  <p>Here is the code</p>
  
  <p>This is my class to call Outlook</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Xml.Linq;
  using Outlook = Microsoft.Office.Interop.Outlook;
  using Office = Microsoft.Office.Core;
  using System.Diagnostics;
  using System.ComponentModel;
  using System.Windows.Forms;
  
  namespace OutlookAddIn1
  {
      public partial class ThisAddIn
      {
          XMLFileCreation xmlfile = new XMLFileCreation();
          Outlook.Explorer currentExplorer = null;
  
  
  
          // public ThisAddIn()
          //{
  
          //}
  
          private void ThisAddIn_Startup(object sender, System.EventArgs e)
          {
              //Globals.Ribbons.Ribbon1.button1.Checked = true;
              currentExplorer = this.Application.ActiveExplorer();
              currentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);
  
          }
  
          private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
          {
  
          }
          private void CurrentExplorer_Event()
          {
              Outlook.MAPIFolder selectedFolder =
                  this.Application.ActiveExplorer().CurrentFolder;
              try
              {
                  if (this.Application.ActiveExplorer().Selection.Count &gt; 0)
                  {
                          Object seleObject = this.Application.ActiveExplorer().Selection[1];
                          Outlook.MailItem mailItem = (seleObject as Outlook.MailItem);
                          string Subject= mailItem.Subject.ToString();
                          string TO= mailItem.To.ToString();
                          string Body=mailItem.Body.ToString();
                          string SenderEmail=mailItem.SenderEmailAddress.ToString();
                          string SenderName=mailItem.SenderName .ToString();
                          xmlfile.CreateXMLFile(Subject, TO, SenderName, SenderEmail, Body);
                  }
              }
              catch
              {
  
              }
          }
              #region VSTO generated code
  
              /// &lt;summary&gt;
              /// Required method for Designer support - do not modify
              /// the contents of this method with the code editor.
              /// &lt;/summary&gt;
              private void InternalStartup()
          {
              this.Startup += new System.EventHandler(ThisAddIn_Startup);
              this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
          }
  
          #endregion
      }
  }
  </code></pre>
  
  <p>With this class, I called to create an XML file</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using System.Xml;
  
  namespace OutlookAddIn1
  {
      class XMLFileCreation
      {
  
          public void CreateXMLFile(string Subject, string TO, string SenderName,string SenderEmail,string Body)
          {
              XmlTextWriter xWrite = new XmlTextWriter("C:\\Users\\xxxxxxxx\\Desktop\\Outloot-Marketing\\Marketing.xml", Encoding.UTF8);
              xWrite.Formatting = Formatting.Indented;
              xWrite.WriteStartElement("Email");
              xWrite.WriteStartElement("TO");
              xWrite.WriteString(TO);
              xWrite.WriteEndElement();
              xWrite.WriteStartElement("FROM");
              xWrite.WriteString(SenderName);
              xWrite.WriteEndElement();
              xWrite.WriteStartElement("SENDER_EMAIL");
              xWrite.WriteString(SenderEmail);
              xWrite.WriteEndElement();
              xWrite.WriteStartElement("SUBJECT");
              xWrite.WriteString(Subject);
              xWrite.WriteEndElement();
              xWrite.WriteStartElement("EMAIL_BODY");
              xWrite.WriteString(Body);
              xWrite.WriteEndElement();
              xWrite.WriteEndElement();
              xWrite.Close();
  
          }
  
      }
  }
  </code></pre>
  
  <p>With this class, I am trying to create the ribbon and the botton 
  My idea is when the user clicks on the botton the email selected will be saved as an XML file. However, I have not been successful in display the ribbon in my outlook. I need help displaying the ribbon and the botton as well. I will appreciate any help fro you.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using Microsoft.Office.Tools.Ribbon;
  
  namespace OutlookAddIn1
  {
      public partial class Ribbon1
      {
  
          private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
          {
  
  
          }
  
          private void button1_Click(object sender, RibbonControlEventArgs e)
          {
              //  ThisAddIn mainapp = new ThisAddIn();
              if (((RibbonToggleButton)sender).Checked)
              {
                  MessageBox.Show("Hello");
              }
              else
              {
                  MessageBox.Show("Hello from the else");
  
              }
          }
      }
  }
  </code></pre>