none
How could I make my Ribbon Designer display in my Outlook 365 ProPlus RRS feed

  • Question

  • Hello All,

    I need your help. I am new, creating VSTO. I created an add-in, the code work, and it creates my XML, such as I want it. However, the ribbon and the button do not get to show in my outlook. 

    My Idea is when the user clicks the button on the email selected, it got save into an XML file.

    Here is the 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 > 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

                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }

            #endregion
        }
    }
    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();

            }

        }
    }
    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");

                }
            }
        }
    }

    Monday, February 24, 2020 3:53 PM