本文整理汇总了C#中ActiveUp.Net.Mail.Message.AddAttachmentFromString方法的典型用法代码示例。如果您正苦于以下问题:C# Message.AddAttachmentFromString方法的具体用法?C# Message.AddAttachmentFromString怎么用?C# Message.AddAttachmentFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveUp.Net.Mail.Message
的用法示例。
在下文中一共展示了Message.AddAttachmentFromString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetrieveMessageObject
/// <summary>
/// Retrieves the message at the given index.
/// </summary>
/// <param name="message_index">The index of the message to be retrieved.</param>
/// <returns>A Message object representing the message.</returns>
/// <example>
/// <code>
/// C#
///
/// Pop3Client pop = new Pop3Client();
/// pop.Connect("mail.myhost.com","user","pass");
/// Message message = pop.RetrieveMessageObject(1);
/// pop.Disconnect();
///
/// VB.NET
///
/// Dim pop As New Pop3Client
/// pop.Connect("mail.myhost.com","user","pass")
/// Dim message as Message = pop.RetrieveMessageObject(1)
/// pop.Disconnect()
///
/// JScript.NET
///
/// var pop:Pop3Client = new Pop3Client();
/// pop.Connect("mail.myhost.com","user","pass");
/// var message:Message = pop.RetrieveMessageObject(1);
/// pop.Disconnect();
/// </code>
/// </example>
public Message RetrieveMessageObject(int message_index)
{
var msg = RetrieveMessageString(message_index);
Message message;
try
{
message = Parser.ParseMessage(ref msg);
}
catch (Exception ex)
{
if (ex is ParsingException || ex is IndexOutOfRangeException)
{
var header_string = RetrieveHeaderString(message_index);
Header header;
if (!Parser.TryParseDefectiveHeader(header_string, out header))
throw;
message = new Message(header);
message.AddAttachmentFromString("original_message.eml", msg);
message.OriginalData = Encoding.GetEncoding("iso-8859-1").GetBytes(msg);
message.HasParseError = true;
}
else
throw;
}
return message;
}
示例2: GetPop3MessageAfterParseError
private Message GetPop3MessageAfterParseError(Pop3Client client, int message_index)
{
var header = client.RetrieveHeaderObject(message_index);
var eml_message_string = client.RetrieveMessageString(message_index);
var message = new Message(header);
message.AddAttachmentFromString("original_message.eml", eml_message_string);
return message;
}
示例3: ParseMessage
/// <summary>
/// Parses a Message from a string formatted accordingly to the RFC822.
/// </summary>
/// <param name="msg">The string containing the message data to be parsed.</param>
/// <returns>The parsed message as a Message object.</returns>
/// <example>
/// <code>
/// C#
///
/// Message message = Parser.ParseMessageString(rfc822string);
/// //Expose the subject
/// string subject = message.Subject;
///
/// VB.NET
///
/// Dim message As Message = Parser.ParseMessageString(rfc822string)
/// 'Expose the subject
/// Dim subject As String = message.Subject
///
/// JScript.NET
///
/// var message:Message = Parser.ParseMessageString(rfc822string);
/// //Expose the subject
/// var subject:string = message.Subject;
/// </code>
/// </example>
public static Message ParseMessage(ref string msg)
{
var message = new Message();
try
{
// Build a part tree and get all headers.
var part = ParseMimePart(ref msg, message);
// Fill a new message object with the new information.
//message.OriginalData = data;
message.HeaderFields = part.HeaderFields;
message.HeaderFieldNames = part.HeaderFieldNames;
// Dispatch header fields to corresponding object.
foreach (var key in message.HeaderFields.AllKeys)
{
var name = key;
var value = message.HeaderFields[key];
// TODO : Fix trace
if (name.Equals("received")) message.Trace.Add(ParseTrace(key + ": " + value));
else if (name.Equals("to")) message.To = ParseAddresses(value);
else if (name.Equals("cc")) message.Cc = ParseAddresses(value);
else if (name.Equals("bcc")) message.Bcc = ParseAddresses(value);
else if (name.Equals("reply-to")) message.ReplyTo = ParseAddress(value);
else if (name.Equals("from")) message.From = ParseAddress(value);
else if (name.Equals("sender")) message.Sender = ParseAddress(value);
else if (name.Equals("content-type")) message.ContentType = GetContentType(key + ": " + value);
else if (name.Equals("content-disposition"))
message.ContentDisposition = GetContentDisposition(key + ": " + value);
else if (name.Equals("domainkey-signature"))
message.Signatures.DomainKeys = Signature.Parse(key + ": " + value, message);
}
if (message.ContentType.MimeType.Equals("application/pkcs7-mime")
|| message.ContentType.MimeType.Equals("application/x-pkcs7-mime"))
{
if (message.ContentType.Parameters["smime-type"] != null
&& message.ContentType.Parameters["smime-type"].Equals("enveloped-data"))
{
message.IsSmimeEncrypted = true;
}
if (message.ContentType.Parameters["smime-type"] != null
&& message.ContentType.Parameters["smime-type"].Equals("signed-data"))
{
message.HasSmimeSignature = true;
}
}
if (message.ContentType.MimeType.Equals("multipart/signed"))
{
message.HasSmimeDetachedSignature = true;
}
if (message.ContentType.MimeType.Equals("multipart/report"))
{
message.IsMultipartReport = true;
}
// Keep a reference to the part tree within the new Message object.
message.PartTreeRoot = part;
// Dispatch the part tree content to the appropriate collections and properties.
DispatchParts(ref message);
// Check message for text limit
const int message_limit = 500000; // 500kb
if (!string.IsNullOrEmpty(message.BodyHtml.Text))
{
if (message.BodyHtml.Text.Length > message_limit)
{
var charset = (!string.IsNullOrEmpty(message.BodyHtml.Charset) ? message.BodyHtml.Charset : "iso-8859-1");
message.AddAttachmentFromString("original_message.html",
//.........这里部分代码省略.........
示例4: GetImapMessageAfterParseError
private Message GetImapMessageAfterParseError(Mailbox mb, int uid)
{
var header = GetImapHeader(mb, uid);
var message = new Message(header);
var eml_message_string = mb.Fetch.UidMessageString(uid);
message.AddAttachmentFromString("original_message.eml", eml_message_string);
return message;
}