// SmtpMisc.cs
//
// This file is based (in parts) on SmtpEmailer code by Steaven Woyan (mailto:swoyan@hotmail.com),
// and by extension on logic/code design from PJ Naughter's C++ SMTP package
// located at http://www.naughter.com/smpt.html.
//
// The original code has been adapted for use in Aggie by Ziv Caspi.
// See SmtpBatchMailer.cs for a list of changes.
using System;
namespace Bitworking.Smtp{
/// <summary>
/// Possible response values returned from an SMTP host.
/// </summary>
public enum SmtpResponseCodes {
SystemStatus = 211,
Help = 214,
Ready = 220,
ClosingChannel = 221,
RequestCompleted = 250,
UserNotLocalOk = 251,
StartInput = 354,
ServiceNotAvailable = 421,
MailBoxUnavailable = 450,
RequestAborted = 451,
InsufficientStorage = 452,
Error = 500,
SyntaxError = 501,
CommandNotImplemented = 502,
BadSequence = 503,
CommandParameterNotImplemented = 504,
MailBoxNotFound = 550,
UserNotLocalBad = 551,
ExceededStorage = 552,
MailBoxNameNotValid = 553,
TransactionFailed = 554
} // enum SmtpResponseCodes
/// <summary>
/// Specifies how is the attachment carried by the message.
/// </summary>
public enum HowAttached {
/// <summary>
/// A regular attachment, external to the body.
/// </summary>
Externally = 0,
/// <summary>
/// Inlined MIME attachment (such as HTML images)
/// </summary>
Inlined = 1
} // enum HowAttached
/// <summary>
/// Encapsulates the information relevant for a single attachment item.
/// </summary>
public class SmtpAttachment {
#region Private data
// TODO: Remove this: internal static int inlineCount; -- Number of Inlined attachments
// TODO: Remove this: internal static int attachCount; -- Number of ExternalAttachment attachments
/// <summary>
/// The file that holds the attachment data.
/// </summary>
private string filename;
/// <summary>
/// The MIME type of the attachment data (such as application/octet-stream
/// for unknown types).
/// </summary>
private string contentType;
/// <summary>
/// How is the item attached to the mail message.
/// </summary>
private HowAttached howAttached;
#endregion
#region Properties
public HowAttached HowAttached {
get { return howAttached; }
}
public string Filename {
get { return filename; }
}
public string ContentType {
get { return contentType; }
}
#endregion
#region Construction
public SmtpAttachment( string filename, string contentType, HowAttached howAttached ) {
this.filename = filename;
this.contentType = contentType;
this.howAttached = howAttached;
} // SmtpAttachment( string, string, HowAttached )
public SmtpAttachment( string filename )
: this( filename, "application/octet-stream", HowAttached.Externally ) {
} // SmtpAttachment( string )
#endregion
#region System.Object overriders
public override string ToString() {
return filename;
}
#endregion
} // class SmtpAttachment
} // namespace Bitworking.Smtp
|