本文整理汇总了C#中System.Net.Mail.SmtpConnection类的典型用法代码示例。如果您正苦于以下问题:C# SmtpConnection类的具体用法?C# SmtpConnection怎么用?C# SmtpConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SmtpConnection类属于System.Net.Mail命名空间,在下文中一共展示了SmtpConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginGetConnection
internal IAsyncResult BeginGetConnection(ServicePoint servicePoint, ContextAwareResult outerResult, AsyncCallback callback, object state)
{
IAsyncResult result = null;
try
{
this.UpdateServicePoint(servicePoint);
this.connection = new SmtpConnection(this, this.client, this.credentials, this.authenticationModules);
this.connection.Timeout = this.timeout;
if (Logging.On)
{
Logging.Associate(Logging.Web, this, this.connection);
}
if (this.EnableSsl)
{
this.connection.EnableSsl = true;
this.connection.ClientCertificates = this.ClientCertificates;
}
result = this.connection.BeginGetConnection(servicePoint, outerResult, callback, state);
}
catch (Exception exception)
{
throw new SmtpException(SR.GetString("MailHostNotFound"), exception);
}
return result;
}
示例2: BeginSend
internal static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state)
{
MultiAsyncResult result = new MultiAsyncResult(conn, callback, state);
result.Enter();
IAsyncResult result2 = conn.BeginFlush(onWrite, result);
if (result2.CompletedSynchronously)
{
conn.EndFlush(result2);
result.Leave();
}
SmtpReplyReader nextReplyReader = conn.Reader.GetNextReplyReader();
result.Enter();
IAsyncResult result3 = nextReplyReader.BeginReadLines(onReadLines, result);
if (result3.CompletedSynchronously)
{
LineInfo[] infoArray = conn.Reader.CurrentReader.EndReadLines(result3);
if (!(result.Result is Exception))
{
result.Result = infoArray;
}
result.Leave();
}
result.CompleteSequence();
return result;
}
示例3: BeginSend
internal static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state)
{
MultiAsyncResult multiResult = new MultiAsyncResult(conn, callback, state);
multiResult.Enter();
IAsyncResult writeResult = conn.BeginFlush(s_onWrite, multiResult);
if (writeResult.CompletedSynchronously)
{
conn.EndFlush(writeResult);
multiResult.Leave();
}
SmtpReplyReader reader = conn.Reader.GetNextReplyReader();
multiResult.Enter();
//this actually does a read on the stream.
IAsyncResult result = reader.BeginReadLine(s_onReadLine, multiResult);
if (result.CompletedSynchronously)
{
LineInfo info = reader.EndReadLine(result);
if (!(multiResult.Result is Exception))
multiResult.Result = info;
multiResult.Leave();
}
multiResult.CompleteSequence();
return multiResult;
}
示例4: PrepareCommand
private static void PrepareCommand(SmtpConnection conn)
{
if (conn.IsStreamOpen)
{
throw new InvalidOperationException(SR.GetString("SmtpDataStreamOpen"));
}
conn.BufferBuilder.Append(SmtpCommands.Data);
}
示例5: SendMailAsyncResult
internal SendMailAsyncResult(SmtpConnection connection, string from, MailAddressCollection toCollection, string deliveryNotify, AsyncCallback callback, object state) : base(null, state, callback)
{
this.failedRecipientExceptions = new ArrayList();
this.toCollection = toCollection;
this.connection = connection;
this.from = from;
this.deliveryNotify = deliveryNotify;
}
示例6: PrepareCommand
private static void PrepareCommand(SmtpConnection conn, string type, string message)
{
conn.BufferBuilder.Append(SmtpCommands.Auth);
conn.BufferBuilder.Append(type);
conn.BufferBuilder.Append((byte) 0x20);
conn.BufferBuilder.Append(message);
conn.BufferBuilder.Append(SmtpCommands.CRLF);
}
示例7: PrepareCommand
private static void PrepareCommand(SmtpConnection conn, byte[] command, string from)
{
if (conn.IsStreamOpen)
{
throw new InvalidOperationException(SR.GetString("SmtpDataStreamOpen"));
}
conn.BufferBuilder.Append(command);
conn.BufferBuilder.Append(from);
conn.BufferBuilder.Append(SmtpCommands.CRLF);
}
示例8: Send
internal static SmtpStatusCode Send(SmtpConnection conn, out string response)
{
conn.Flush();
SmtpReplyReader reader = conn.Reader.GetNextReplyReader();
LineInfo info = reader.ReadLine();
response = info.Line;
reader.Close();
return info.StatusCode;
}
示例9: GetConnection
internal void GetConnection(string host, int port)
{
try
{
_connection = new SmtpConnection(this, _client, _credentials, _authenticationModules);
_connection.Timeout = _timeout;
if (MailEventSource.Log.IsEnabled()) MailEventSource.Log.Associate(this, _connection);
if (EnableSsl)
{
_connection.EnableSsl = true;
_connection.ClientCertificates = ClientCertificates;
}
_connection.GetConnection(host, port);
}
finally { }
}
示例10: BeginSend
internal static IAsyncResult BeginSend(SmtpConnection conn, byte[] command, string from, AsyncCallback callback, object state)
{
PrepareCommand(conn, command, from);
return CheckCommand.BeginSend(conn, callback, state);
}
示例11: BeginGetConnection
internal IAsyncResult BeginGetConnection(ContextAwareResult outerResult, AsyncCallback callback, object state, string host, int port)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this);
IAsyncResult result = null;
try
{
_connection = new SmtpConnection(this, _client, _credentials, _authenticationModules);
_connection.Timeout = _timeout;
if (NetEventSource.IsEnabled) NetEventSource.Associate(this, _connection);
if (EnableSsl)
{
_connection.EnableSsl = true;
_connection.ClientCertificates = ClientCertificates;
}
result = _connection.BeginGetConnection(outerResult, callback, state, host, port);
}
catch (Exception innerException)
{
throw new SmtpException(SR.MailHostNotFound, innerException);
}
if (NetEventSource.IsEnabled)
{
NetEventSource.Info(this, "Sync completion");
NetEventSource.Exit(this);
}
return result;
}
示例12: BeginGetConnection
internal IAsyncResult BeginGetConnection(ServicePoint servicePoint, ContextAwareResult outerResult, AsyncCallback callback, object state)
{
GlobalLog.Enter("SmtpTransport#" + ValidationHelper.HashString(this) + "::BeginConnect");
IAsyncResult result = null;
try{
UpdateServicePoint(servicePoint);
connection = new SmtpConnection(this, client, credentials, authenticationModules);
connection.Timeout = timeout;
if(Logging.On)Logging.Associate(Logging.Web, this, connection);
if (EnableSsl)
{
connection.EnableSsl = true;
connection.ClientCertificates = ClientCertificates;
}
result = connection.BeginGetConnection(servicePoint, outerResult, callback, state);
}
catch(Exception innerException){
throw new SmtpException(SR.GetString(SR.MailHostNotFound), innerException);
}
GlobalLog.Leave("SmtpTransport#" + ValidationHelper.HashString(this) + "::BeginConnect [....] Completion");
return result;
}
示例13: Send
internal static LineInfo Send(SmtpConnection conn, string type, string message)
{
PrepareCommand(conn, type, message);
return CheckResponse(ReadLinesCommand.Send(conn));
}
示例14: Send
internal static void Send(SmtpConnection conn)
{
string str;
PrepareCommand(conn);
CheckResponse(CheckCommand.Send(conn, out str), str);
}
示例15: ConnectAndHandshakeAsyncResult
internal ConnectAndHandshakeAsyncResult(SmtpConnection connection, string host, int port, ContextAwareResult outerResult, AsyncCallback callback, object state) :
base(null, state, callback)
{
_connection = connection;
_host = host;
_port = port;
_outerResult = outerResult;
}