0

I am attempting to set the default signature for new emails and email replies in a VSTO Add-In using Interop. I am utilizing code from this Stack Overflow post: Creating and adding Outlook Signature. The code appears to work when replying to an email via Outlook, but when composing a new email, the signature is not inserted.

This is the code I am currently using:

using Word = Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;

public void UpdateOlSignature()
{
   string sigName = "MORE";

   Word.Application app = new Word.Application() { Visible = false, WindowState = Word.WdWindowState.wdWindowStateMinimize };
   Word.EmailSignature opt = app.EmailOptions.EmailSignature;

   opt.NewMessageSignature = sigName;
   opt.ReplyMessageSignature = sigName;

   app.Quit(Word.WdSaveOptions.wdSaveChanges);
   Marshal.ReleaseComObject(app);
}

UpdateOlSignature() is called when the Add-In loads in the "Ribbon1_Load" event.

Is there an alternate way to set the default signature programmatically or any hints on debugging the problem (Registry, etc.)? I can select the email signature manually, when drafting a new one.

When I go to the email settings in Outlook (Options -> Email -> Signatures), the signature is present, but the dropdowns for the default values at the bottom are empty.

0 Answers0