本文整理汇总了C#中LumiSoft.Net.MIME.MIME_Encoding_EncodedWord.Encode方法的典型用法代码示例。如果您正苦于以下问题:C# MIME_Encoding_EncodedWord.Encode方法的具体用法?C# MIME_Encoding_EncodedWord.Encode怎么用?C# MIME_Encoding_EncodedWord.Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LumiSoft.Net.MIME.MIME_Encoding_EncodedWord
的用法示例。
在下文中一共展示了MIME_Encoding_EncodedWord.Encode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString
/// <summary>
/// Returns address as string value.
/// </summary>
/// <param name="wordEncoder">8-bit words ecnoder. Value null means that words are not encoded.</param>
/// <returns>Returns address as string value.</returns>
public override string ToString(MIME_Encoding_EncodedWord wordEncoder)
{
StringBuilder retVal = new StringBuilder();
if(string.IsNullOrEmpty(m_DisplayName)){
retVal.Append(":");
}
else{
if(MIME_Encoding_EncodedWord.MustEncode(m_DisplayName)){
retVal.Append(wordEncoder.Encode(m_DisplayName) + ":");
}
else{
retVal.Append(TextUtils.QuoteString(m_DisplayName) + ":");
}
}
for(int i=0;i<m_pList.Count;i++){
retVal.Append(m_pList[i].ToString(wordEncoder));
if(i < (m_pList.Count - 1)){
retVal.Append(",");
}
}
retVal.Append(";");
return retVal.ToString();
}
示例2: ConstructAddress
/// <summary>
/// Constructs ENVELOPE address structure.
/// </summary>
/// <param name="address">Mailbox address.</param>
/// <param name="wordEncoder">Unicode words encoder.</param>
/// <returns></returns>
private static string ConstructAddress(Mail_t_Mailbox address,MIME_Encoding_EncodedWord wordEncoder)
{
/* An address structure is a parenthesized list that describes an
electronic mail address. The fields of an address structure
are in the following order: personal name, [SMTP]
at-domain-list (source route), mailbox name, and host name.
*/
// NOTE: all header fields and parameters must in ENCODED form !!!
StringBuilder retVal = new StringBuilder();
retVal.Append("(");
// personal name
if(address.DisplayName != null){
retVal.Append(TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.DisplayName))));
}
else{
retVal.Append("NIL");
}
// source route, always NIL (not used nowdays)
retVal.Append(" NIL");
// mailbox name
retVal.Append(" " + TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.LocalPart))));
// host name
if(address.Domain != null){
retVal.Append(" " + TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.Domain))));
}
else{
retVal.Append(" NIL");
}
retVal.Append(")");
return retVal.ToString();
}
示例3: ConstructEnvelope
/// <summary>
/// Construct secified mime entity ENVELOPE string.
/// </summary>
/// <param name="entity">Mail message.</param>
/// <returns></returns>
public static string ConstructEnvelope(Mail_Message entity)
{
/* RFC 3501 7.4.2
ENVELOPE
A parenthesized list that describes the envelope structure of a
message. This is computed by the server by parsing the
[RFC-2822] header into the component parts, defaulting various
fields as necessary.
The fields of the envelope structure are in the following
order: date, subject, from, sender, reply-to, to, cc, bcc,
in-reply-to, and message-id. The date, subject, in-reply-to,
and message-id fields are strings. The from, sender, reply-to,
to, cc, and bcc fields are parenthesized lists of address
structures.
An address structure is a parenthesized list that describes an
electronic mail address. The fields of an address structure
are in the following order: personal name, [SMTP]
at-domain-list (source route), mailbox name, and host name.
[RFC-2822] group syntax is indicated by a special form of
address structure in which the host name field is NIL. If the
mailbox name field is also NIL, this is an end of group marker
(semi-colon in RFC 822 syntax). If the mailbox name field is
non-NIL, this is a start of group marker, and the mailbox name
field holds the group name phrase.
If the Date, Subject, In-Reply-To, and Message-ID header lines
are absent in the [RFC-2822] header, the corresponding member
of the envelope is NIL; if these header lines are present but
empty the corresponding member of the envelope is the empty
string.
Note: some servers may return a NIL envelope member in the
"present but empty" case. Clients SHOULD treat NIL and
empty string as identical.
Note: [RFC-2822] requires that all messages have a valid
Date header. Therefore, the date member in the envelope can
not be NIL or the empty string.
Note: [RFC-2822] requires that the In-Reply-To and
Message-ID headers, if present, have non-empty content.
Therefore, the in-reply-to and message-id members in the
envelope can not be the empty string.
If the From, To, cc, and bcc header lines are absent in the
[RFC-2822] header, or are present but empty, the corresponding
member of the envelope is NIL.
If the Sender or Reply-To lines are absent in the [RFC-2822]
header, or are present but empty, the server sets the
corresponding member of the envelope to be the same value as
the from member (the client is not expected to know to do
this).
Note: [RFC-2822] requires that all messages have a valid
From header. Therefore, the from, sender, and reply-to
members in the envelope can not be NIL.
ENVELOPE ("date" "subject" from sender reply-to to cc bcc "in-reply-to" "messageID")
*/
// NOTE: all header fields and parameters must in ENCODED form !!!
MIME_Encoding_EncodedWord wordEncoder = new MIME_Encoding_EncodedWord(MIME_EncodedWordEncoding.B,Encoding.UTF8);
wordEncoder.Split = false;
StringBuilder retVal = new StringBuilder();
retVal.Append("ENVELOPE (");
// date
try{
if(entity.Date != DateTime.MinValue){
retVal.Append(TextUtils.QuoteString(MIME_Utils.DateTimeToRfc2822(entity.Date)));
}
else{
retVal.Append("NIL");
}
}
catch{
retVal.Append("NIL");
}
// subject
if(entity.Subject != null){
//retVal.Append(" " + TextUtils.QuoteString(wordEncoder.Encode(entity.Subject)));
string val = wordEncoder.Encode(entity.Subject);
retVal.Append(" {" + val.Length + "}\r\n" + val);
}
else{
retVal.Append(" NIL");
}
//.........这里部分代码省略.........
示例4: ConstructParts
//.........这里部分代码省略.........
body location
A string list giving the body content URI as defined in [LOCATION].
Any following extension data are not yet defined in this
version of the protocol, and would be as described above under
multipart extension data.
// We don't construct extention fields like rfc says:
Server implementations MUST NOT send such
extension data until it has been defined by a revision of this
protocol.
contentTypeMainMediaType - Example: 'TEXT'
contentTypeSubMediaType - Example: 'PLAIN'
conentTypeParameters - Example: '("CHARSET" "iso-8859-1" ...)'
contentID - Content-ID: header field value.
contentDescription - Content-Description: header field value.
contentEncoding - Content-Transfer-Encoding: header field value.
contentSize - mimeEntity ENCODED data size
[envelope] - NOTE: included only if contentType = "message" !!!
[contentLines] - number of ENCODED data lines. NOTE: included only if contentType = "text" !!!
// Basic fields for multipart
(nestedMimeEntries) contentTypeSubMediaType
// Basic fields for non-multipart
contentTypeMainMediaType contentTypeSubMediaType (conentTypeParameters) contentID contentDescription contentEncoding contentSize [envelope] [contentLine]
*/
MIME_Encoding_EncodedWord wordEncoder = new MIME_Encoding_EncodedWord(MIME_EncodedWordEncoding.B,Encoding.UTF8);
wordEncoder.Split = false;
StringBuilder retVal = new StringBuilder();
// Multipart message
if(entity.Body is MIME_b_Multipart){
retVal.Append("(");
// Construct child entities.
foreach(MIME_Entity childEntity in ((MIME_b_Multipart)entity.Body).BodyParts){
// Construct child entity. This can be multipart or non multipart.
retVal.Append(ConstructParts(childEntity,bodystructure));
}
// Add contentTypeSubMediaType
if(entity.ContentType != null && entity.ContentType.SubType != null){
retVal.Append(" \"" + entity.ContentType.SubType + "\"");
}
else{
retVal.Append(" NIL");
}
retVal.Append(")");
}
// Single part message
else{
retVal.Append("(");
// NOTE: all header fields and parameters must in ENCODED form !!!
// Add contentTypeMainMediaType
if(entity.ContentType != null && entity.ContentType.Type != null){
retVal.Append("\"" + entity.ContentType.Type + "\"");
示例5: ToString
/// <summary>
/// Returns address as string value.
/// </summary>
/// <param name="wordEncoder">8-bit words ecnoder. Value null means that words are not encoded.</param>
/// <returns>Returns address as string value.</returns>
public override string ToString(MIME_Encoding_EncodedWord wordEncoder)
{
if(string.IsNullOrEmpty(m_DisplayName)){
return "<" + m_Address + ">";
}
else{
if(MIME_Encoding_EncodedWord.MustEncode(m_DisplayName)){
return wordEncoder.Encode(m_DisplayName) + " " + "<" + m_Address + ">";
}
else{
return TextUtils.QuoteString(m_DisplayName) + " " + "<" + m_Address + ">";
}
}
}
示例6: ToString
/// <summary>
/// Returns header field as string.
/// </summary>
/// <param name="wordEncoder">8-bit words ecnoder. Value null means that words are not encoded.</param>
/// <param name="parmetersCharset">Charset to use to encode 8-bit characters. Value null means parameters not encoded.</param>
/// <returns>Returns header field as string.</returns>
public override string ToString(MIME_Encoding_EncodedWord wordEncoder,Encoding parmetersCharset)
{
if(m_ParseValue != null){
return m_ParseValue;
}
else{
if(wordEncoder != null){
return m_Name + ": " + wordEncoder.Encode(m_Value) + "\r\n";
}
else{
return m_Name + ": " + m_Value + "\r\n";
}
}
}