C#使用签名发送电子邮件

时间:2018-02-28 22:21:35

标签: c# winforms email gmail

我已在我的Gmail帐户上配置了签名。但是当我从winforms发送它时,它似乎不包括签名。这是我的代码:

               try
            {
                SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                NetworkCredential credential = new NetworkCredential("xxxxx@gmail.com", "xxxx");
                client.Timeout = 20000;

                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress("xxxxx@gmail.com", "Test Mail");
                mailMessage.Priority = MailPriority.High;
                mailMessage.IsBodyHtml = true;

                mailMessage.To.Add("xxxxx@gmail.com");

                mailMessage.Subject = "Test Mail"

                mailMessage.Body = "This is a <b>test</b> av <b>{2}</b> mail.";

                client.Credentials = credential;
                client.EnableSsl = true;

                client.Send(mailMessage);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex, "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

0 个答案:

没有答案