none
how to embed an image in an vsto addin for outlook in c# RRS feed

  • Question

  • Hi,

    I have made an outlook 2013 vsto application for appointments.the application sets text in the appointment body using

    currentAppointment.Body


    Now i want to set an image to the appointment body.one idea ive got is to use the

    currentAppointment.GetInspector.WordEditor

    or using the clipboard

    System.Windows.Forms.Clipboard.SetImage();



    but i didn't find any workable examples in this case. any idea how it can be done

    Thanks.

    Thursday, January 18, 2018 6:56 PM

All replies

  • Hello cornelius11,

    In fact, the WordEditor is a word document file. So we could get the document and then try to insert a picture to a word document.

    Here is the simply code.

    //add reference to Microsoft.Office.Interop.Word
    using Outlook = Microsoft.Office.Interop.Outlook;
    using Word = Microsoft.Office.Interop.Word;
    
    
     private void button1_Click(object sender, RibbonControlEventArgs e)
            {
                //not clearly how you get currentAppointment,just simply code to get the word editor
                //Word.Document document=currentAppointment.GetInspector.WordEditor
                Outlook.Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
                Word.Document document = inspector.WordEditor;
    
                string ImagePath = @"C:\Users\v-guaxu\Desktop\Capture.PNG";
               
                if (document.Application.Selection == null)
                {
                    MessageBox.Show("Please select where you want to insert the picture");
                }
                else {
                    //insert image to where you select
                    document.Application.Selection.InlineShapes.AddPicture(ImagePath);
                }
            }

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 19, 2018 2:43 AM