当前位置: 首页>>代码示例>>C#>>正文


C# Mail.VerifySignature方法代码示例

本文整理汇总了C#中Mail.VerifySignature方法的典型用法代码示例。如果您正苦于以下问题:C# Mail.VerifySignature方法的具体用法?C# Mail.VerifySignature怎么用?C# Mail.VerifySignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mail的用法示例。


在下文中一共展示了Mail.VerifySignature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _GenerateHtmlForEmail

        private static PurchaseEmail _GenerateHtmlForEmail(string htmlName, string emlFile, string tempFolder, PurchaseEmail currentHtMLEmail)
        {
            Mail oMail = new Mail("TryIt");
            oMail.Load(emlFile, false);

            if (oMail.IsEncrypted)
            {
                try
                {
                    // This email is encrypted, we decrypt it by user default certificate.
                    oMail = oMail.Decrypt(null);
                }
                catch (Exception ep)
                {
                    MessageBox.Show(ep.Message);
                    oMail.Load(emlFile, false);
                }
            }

            if (oMail.IsSigned)
            {
                try
                {
                    // This email is digital signed.
                    EAGetMail.Certificate cert = oMail.VerifySignature();
                    //Console.WriteLine("This email contains a valid digital signature.");
                }
                catch (Exception ep)
                {
                    MessageBox.Show(ep.Message);
                }
            }

            // Parse html body
            string html = oMail.HtmlBody;
            var hdr = new StringBuilder();

            // Parse sender
            hdr.Append("<font face=\"Courier New,Arial\" size=2>");
            hdr.Append("<b>From:</b> " + _FormatHtmlTag(oMail.From.ToString()) + "<br>");

            // Parse to
            MailAddress[] addrs = oMail.To;
            int count = addrs.Length;
            if (count > 0)
            {
                hdr.Append("<b>To:</b> ");
                for (int i = 0; i < count; i++)
                {
                    hdr.Append(_FormatHtmlTag(addrs[i].ToString()));
                    if (i < count - 1)
                    {
                        hdr.Append(";");
                    }
                }
                hdr.Append("<br>");
            }

            // Parse cc
            addrs = oMail.Cc;

            count = addrs.Length;
            if (count > 0)
            {
                hdr.Append("<b>Cc:</b> ");
                for (int i = 0; i < count; i++)
                {
                    hdr.Append(_FormatHtmlTag(addrs[i].ToString()));
                    if (i < count - 1)
                    {
                        hdr.Append(";");
                    }
                }
                hdr.Append("<br>");
            }

            hdr.Append(String.Format("<b>Subject:</b>{0}<br>\r\n", _FormatHtmlTag(oMail.Subject)));

            // Parse attachments and save to local folder
            Attachment[] atts = oMail.Attachments;
            count = atts.Length;
            if (count > 0)
            {
                if (!Directory.Exists(tempFolder))
                    Directory.CreateDirectory(tempFolder);

                hdr.Append("<b>Attachments:</b>");
                for (int i = 0; i < count; i++)
                {
                    Attachment att = atts[i];

                    // this attachment is in OUTLOOK RTF format, decode it here.
                    if (String.Compare(att.Name, "winmail.dat") == 0)
                    {
                        Attachment[] tatts = null;
                        try
                        {
                            tatts = Mail.ParseTNEF(att.Content, true);
                        }
                        catch (Exception ep)
//.........这里部分代码省略.........
开发者ID:no1redsfan,项目名称:WeListenPlayer,代码行数:101,代码来源:PurchaseEmailHandler.cs


注:本文中的Mail.VerifySignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。