Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / SmtpException.cs / 1305376 / SmtpException.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Mail { using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; using System.Security.Permissions; [Serializable] public class SmtpException : Exception, ISerializable { SmtpStatusCode statusCode = SmtpStatusCode.GeneralFailure; static string GetMessageForStatus(SmtpStatusCode statusCode, string serverResponse) { return GetMessageForStatus(statusCode)+" "+SR.GetString(SR.MailServerResponse,serverResponse); } static string GetMessageForStatus(SmtpStatusCode statusCode) { switch (statusCode) { default : case SmtpStatusCode.CommandUnrecognized: return SR.GetString(SR.SmtpCommandUnrecognized); case SmtpStatusCode.SyntaxError: return SR.GetString(SR.SmtpSyntaxError); case SmtpStatusCode.CommandNotImplemented: return SR.GetString(SR.SmtpCommandNotImplemented); case SmtpStatusCode.BadCommandSequence: return SR.GetString(SR.SmtpBadCommandSequence); case SmtpStatusCode.CommandParameterNotImplemented: return SR.GetString(SR.SmtpCommandParameterNotImplemented); case SmtpStatusCode.SystemStatus: return SR.GetString(SR.SmtpSystemStatus); case SmtpStatusCode.HelpMessage: return SR.GetString(SR.SmtpHelpMessage); case SmtpStatusCode.ServiceReady: return SR.GetString(SR.SmtpServiceReady); case SmtpStatusCode.ServiceClosingTransmissionChannel: return SR.GetString(SR.SmtpServiceClosingTransmissionChannel); case SmtpStatusCode.ServiceNotAvailable: return SR.GetString(SR.SmtpServiceNotAvailable); case SmtpStatusCode.Ok: return SR.GetString(SR.SmtpOK); case SmtpStatusCode.UserNotLocalWillForward: return SR.GetString(SR.SmtpUserNotLocalWillForward); case SmtpStatusCode.MailboxBusy: return SR.GetString(SR.SmtpMailboxBusy); case SmtpStatusCode.MailboxUnavailable: return SR.GetString(SR.SmtpMailboxUnavailable); case SmtpStatusCode.LocalErrorInProcessing: return SR.GetString(SR.SmtpLocalErrorInProcessing); case SmtpStatusCode.UserNotLocalTryAlternatePath: return SR.GetString(SR.SmtpUserNotLocalTryAlternatePath); case SmtpStatusCode.InsufficientStorage: return SR.GetString(SR.SmtpInsufficientStorage); case SmtpStatusCode.ExceededStorageAllocation: return SR.GetString(SR.SmtpExceededStorageAllocation); case SmtpStatusCode.MailboxNameNotAllowed: return SR.GetString(SR.SmtpMailboxNameNotAllowed); case SmtpStatusCode.StartMailInput: return SR.GetString(SR.SmtpStartMailInput); case SmtpStatusCode.TransactionFailed: return SR.GetString(SR.SmtpTransactionFailed); case SmtpStatusCode.ClientNotPermitted: return SR.GetString(SR.SmtpClientNotPermitted); case SmtpStatusCode.MustIssueStartTlsFirst: return SR.GetString(SR.SmtpMustIssueStartTlsFirst); } } public SmtpException(SmtpStatusCode statusCode) : base(GetMessageForStatus(statusCode)) { this.statusCode = statusCode; } public SmtpException(SmtpStatusCode statusCode, string message) : base(message) { this.statusCode = statusCode; } public SmtpException() : this(SmtpStatusCode.GeneralFailure) { } public SmtpException(string message) : base(message) { } public SmtpException(string message, Exception innerException) : base(message, innerException) { } protected SmtpException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base (serializationInfo, streamingContext) { statusCode = (SmtpStatusCode)serializationInfo.GetInt32("Status"); } internal SmtpException(SmtpStatusCode statusCode, string serverMessage, bool serverResponse) : base(GetMessageForStatus(statusCode,serverMessage)) { this.statusCode = statusCode; } internal SmtpException(string message, string serverResponse) : base(message+" "+SR.GetString(SR.MailServerResponse,serverResponse)) { } ///[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.dll is still using pre-v4 security model and needs this demand")] [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { GetObjectData(serializationInfo, streamingContext); } [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.dll is still using pre-v4 security model and needs this demand")] [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext){ base.GetObjectData(serializationInfo, streamingContext); serializationInfo.AddValue("Status", (int)statusCode, typeof(int)); } public SmtpStatusCode StatusCode { get { return this.statusCode; } set { statusCode = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- TogglePatternIdentifiers.cs
- CodeTypeReferenceExpression.cs
- WpfWebRequestHelper.cs
- ClickablePoint.cs
- HtmlShimManager.cs
- BitConverter.cs
- HtmlInputHidden.cs
- DocumentApplicationDocumentViewer.cs
- DocumentOrderQuery.cs
- GroupBoxRenderer.cs
- WebServicesInteroperability.cs
- MasterPageBuildProvider.cs
- DefaultParameterValueAttribute.cs
- ToolStrip.cs
- ISAPIApplicationHost.cs
- ScriptReferenceEventArgs.cs
- CachedCompositeFamily.cs
- TypefaceCollection.cs
- DtrList.cs
- FacetValueContainer.cs
- TraceLevelStore.cs
- MailBnfHelper.cs
- AnnotationDocumentPaginator.cs
- UInt16.cs
- StylusTouchDevice.cs
- HandleExceptionArgs.cs
- SqlNodeAnnotations.cs
- OleDbErrorCollection.cs
- DataIdProcessor.cs
- ResourceExpressionBuilder.cs
- ToolStripSeparatorRenderEventArgs.cs
- WorkflowInstanceProxy.cs
- RuntimeVariablesExpression.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- DescendantOverDescendantQuery.cs
- BCLDebug.cs
- MetadataArtifactLoaderCompositeResource.cs
- OracleColumn.cs
- TextServicesDisplayAttributePropertyRanges.cs
- UnsafeNativeMethods.cs
- UnsafeNetInfoNativeMethods.cs
- CodeRemoveEventStatement.cs
- ErrorReporting.cs
- SoapEnvelopeProcessingElement.cs
- IPEndPoint.cs
- SamlSecurityTokenAuthenticator.cs
- AutomationIdentifierGuids.cs
- CaseExpr.cs
- AttributeQuery.cs
- Translator.cs
- FontFamilyConverter.cs
- IndentTextWriter.cs
- RefreshPropertiesAttribute.cs
- MessageQueueCriteria.cs
- HtmlElement.cs
- PageMediaSize.cs
- DataGrid.cs
- RemotingConfigParser.cs
- WmlLinkAdapter.cs
- TemplatedMailWebEventProvider.cs
- Matrix3DConverter.cs
- WorkerRequest.cs
- FormViewInsertedEventArgs.cs
- WebPartHelpVerb.cs
- StreamProxy.cs
- ModelFunctionTypeElement.cs
- ScrollEvent.cs
- StringUtil.cs
- PopupRootAutomationPeer.cs
- CodeMemberField.cs
- DataServiceClientException.cs
- SecurityRuntime.cs
- TableLayoutSettingsTypeConverter.cs
- DataGridViewTextBoxCell.cs
- OletxResourceManager.cs
- FormViewUpdateEventArgs.cs
- Line.cs
- HScrollProperties.cs
- Crc32.cs
- clipboard.cs
- SimpleLine.cs
- WebControlParameterProxy.cs
- FunctionMappingTranslator.cs
- DllNotFoundException.cs
- WindowsToolbar.cs
- XsdDuration.cs
- LocationUpdates.cs
- ApplicationBuildProvider.cs
- HiddenField.cs
- RequiredFieldValidator.cs
- GroupBoxDesigner.cs
- ExcludeFromCodeCoverageAttribute.cs
- InvalidContentTypeException.cs
- SettingsProperty.cs
- OleDbWrapper.cs
- BoundColumn.cs
- HttpProfileBase.cs
- ConfigurationElementCollection.cs
- HttpApplicationFactory.cs