本文整理汇总了C#中Mail.Decrypt方法的典型用法代码示例。如果您正苦于以下问题:C# Mail.Decrypt方法的具体用法?C# Mail.Decrypt怎么用?C# Mail.Decrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail.Decrypt方法的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)
//.........这里部分代码省略.........