How to insert a signature in outlook via c#

Asked

Viewed 214 times

0

Hello, I am trying to add a signature to an object that sends email, I am able to do everything but the subscription...
Follow the Code, any light will be welcome.

 OutLook._Application outlookObj = new OutLook.Application();
 OutLook.MailItem message = (OutLook.MailItem)outlookObj.CreateItem(OutLook.OlItemType.olMailItem);
 message.To = emailGerente;
 message.CC = "";
 message.Subject = "Conflitos || " + projetoID + "  " + nomeProjeto;
 message.BodyFormat = OutLook.OlBodyFormat.olFormatHTML;
 message.HTMLBody = MontaEmail();
 message.Display(false);

Function that generates HTML:

            var hora = DateTime.Now;

            if (hora.Hour < 12) saudacao = "Bom dia!";
            else saudacao = "Boa tarde!";

            Cabeca = "<h3>" + saudacao + "</h3><br/><h3>Segue os Conflitos Relacionados:</h3>";

            comecoTabela = "<table border= '1'><tr bgcolor= '#00 00 CD'><td><font color= 'FF FF FF'>Projeto</font></td><td>" +
                "<font color= 'FF FF FF'>Extensão</font></td><td><font color= 'FF FF FF'>Fonte</font></td></tr>";

            List<string> projetoConflito = new List<string>();
            List<string> extensao = new List<string>();
            List<string> fonte = new List<string>();

            foreach (DataGridViewRow row in ConflitosGrid.Rows)
            {
                projetoConflito.Add(row.Cells[0].Value.ToString());
                extensao.Add(row.Cells[1].Value.ToString());
                fonte.Add(row.Cells[2].Value.ToString());
            }

            for (var j = 0; j < projetoConflito.Count; j++)
            {
                corpoTabela += "<tr><td>";
                corpoTabela += projetoConflito[j].ToString() + "</td>";
                corpoTabela += "<td>" + extensao[j].ToString() + "</td>";
                corpoTabela += "<td>" + fonte[j].ToString() + "</td>";
                corpoTabela += "</tr>";
            }

            string appData = GetFolderPath(SpecialFolder.ApplicationData) + @"\Microsoft\Assinaturas";

            DirectoryInfo dir = new DirectoryInfo(appData);
            IEnumerable<FileInfo> pegaAssinatura = dir.GetFiles("*.htm*", SearchOption.TopDirectoryOnly);

            foreach (FileInfo assinatura in pegaAssinatura)
            {
                appData = assinatura.FullName; // o caminho da assinatura
            }


            return inicio + Cabeca + comecoTabela + corpoTabela + final;
  • And what is the error presented?

  • not error, I simply need to use the default outlook signature, but I manage to resolve, I printed a default signature and am using via <img> ai worked smoothly

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.