Resolved remove default signature from generated email

Peque

Member
Joined
Sep 14, 2023
Messages
15
Programming Experience
Beginner
Hi Forum
Not sure if this can be handled somehow - But the Scanrio is like this. I'm tring to create an Outlook AddIn to Outlook,
which contains 2 groups - where the one of the groups is 14 buttons. These Buttons generates a email from a 2 shared mailboxes.
But since these are shared Mailbox - Outlook does not allow setting a default mailsignatures for that in Outlook365 - so it'll set the personal email Signature as the default signature.

I've have a way to create a custom signature - but then it'll still add the personal signature below the signature I've created. (But then the autosignature should not be set when replying)

So the users either have to:
1. Delete their personal emailsignature below the Aswer and custom generated signatur
or
2. Add an signature below the custom generated text - above the answer.

Or is I way off here

As my little code as its looking now:
Create custom mailanwser:
// Building the Ansver as a stringbuilder - Appending the HTML code to the Answer
StringBuilder sb = new StringBuilder();

// Inserting the Custom Signature
sb.Append("<table border='0' cellpadding='1' cellspacing='1' style='width:700px'><tbody><tr><td> &nbsp;</td></tr></tbody></table>");
sb.Append("<table border='0' cellpadding='1' cellspacing='1' style='width:700px'><tbody><tr><td> &nbsp;</td></tr></tbody></table>");
sb.Append(ReadSignature());
sb.Append("<table border='0' cellpadding='1' cellspacing='1' style='width:700px'><tbody><tr><td> &nbsp;</td></tr></tbody></table>");

// Creation of the Email - String with Reply All
Outlook.MailItem replyMail = item.ReplyAll();
// Setting the SendOnBehalfOF
replyMail.SentOnBehalfOfName = "Shopname <shop@shops.dk>";
// Adding the String from StringBuilder
replyMail.HTMLBody = sb.ToString() + replyMail.HTMLBody;

// Showing the email before sending - to correct any errors
replyMail.Display();

Is their any way around this problem ( such as a property that option) or a regkey that add options of a custom signature for a shared mailboxex
Can I remove the email signature (that is active as default reply action) or somehow override the function of adding the default signature.

Since naming the sigatures in office365 - is name (mailaccount@itbelong.to).htm/rtf/txt/files - Also tried that solution, but it'll still set the personal email below the Generated, but I create and set a Custom Signature like "Shops (shop@shops.dk).htm" - since its a shared mailboks I cannot set that option since its located under "Installed on this device" is greyed out and not editable, on setting it as default signature when replying from that shared inbox

Tia
P
 
I've not dealt with the Outlook Object Model in over 15 years so take what I say next with a huge grain of salt. See if the application object or a child settings object lets you toggle whether signatures are enabled/disabled. If it does, then you can temporarily disable signatures, insert your preferred custom signature, and then restore the previous setting.

If there is no such setting, the next possible approach is to actually take the message body and tweak the contents to what you like. Don't simply append (or prepend) the signature.
 
Hi Skydiver

Thanks for te reply - (I had my latest programming days in Java back in 2003)
But haven't though of it that way - but its actually quite simple solutions her.
From my start and end of createmail - calling this little
1. time set the value to " "
2. time set the value to "Signatures"
I'm sure it can be written in a nicer way - But that did it for me.

DefaultSignature:
       private string DefaultSignature()
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Office\\16.0\\Common\\General", true);
            if (key != null)
            {
                string value = key.GetValue("Signatures").ToString();
                if (value.Equals("Signatures"))
                {
                    key.SetValue("Signatures", " ");
                }
                else
                {
                    key.SetValue("Signatures", "Signatures");
                }
            }
            return "Nowhere";
        }
 

Latest posts

Back
Top Bottom