本文整理汇总了C#中ActiveUp.Net.Mail.Message.CheckBuiltMimePartTree方法的典型用法代码示例。如果您正苦于以下问题:C# Message.CheckBuiltMimePartTree方法的具体用法?C# Message.CheckBuiltMimePartTree怎么用?C# Message.CheckBuiltMimePartTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveUp.Net.Mail.Message
的用法示例。
在下文中一共展示了Message.CheckBuiltMimePartTree方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendSsl
public static bool SendSsl(Message message, string server, int port)
{
// Ensure that the mime part tree is built
message.CheckBuiltMimePartTree();
ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient();
smtp.ConnectSsl(server, port);
try
{
smtp.Ehlo(System.Net.Dns.GetHostName());
}
catch
{
smtp.Helo(System.Net.Dns.GetHostName());
}
if (message.From.Email != string.Empty) smtp.MailFrom(message.From);
else smtp.MailFrom(message.Sender);
smtp.RcptTo(message.To);
smtp.RcptTo(message.Cc);
smtp.RcptTo(message.Bcc);
smtp.Data(message.ToMimeString());//,(message.Charset!=null ? message.Charset : "iso-8859-1"));
smtp.Disconnect();
return true;
}
示例2: Send
/// <summary>
/// Sends the message using the specified host on the specified port. Secure SASL Authentication is performed according to the requested mechanism.
/// </summary>
/// <param name="message">The message to be sent.</param>
/// <param name="host">The host to be used.</param>
/// <param name="username">The username to be used for authentication.</param>
/// <param name="password">The password to be used for authentication.</param>
/// <param name="mechanism">SASL Mechanism to be used for authentication.</param>
/// <param name="port">The port to be used.</param>
/// <example>
/// <code>
/// C#
///
/// Message message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504);
///
/// VB.NET
///
/// Dim message As New Message
/// message.Subject = "Test"
/// message.From = New Address("[email protected]","John Doe")
/// message.To.Add("[email protected]","Mike Johns")
/// message.BodyText.Text = "Hello this is a test!"
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504)
///
/// JScript.NET
///
/// var message:Message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504);
/// </code>
/// </example>
public static bool Send(Message message, string host, int port, string username, string password, SaslMechanism mechanism)
{
// Ensure that the mime part tree is built
message.CheckBuiltMimePartTree();
ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient();
smtp.Connect(host,port);
try
{
smtp.Ehlo(System.Net.Dns.GetHostName());
}
catch
{
smtp.Helo(System.Net.Dns.GetHostName());
}
smtp.Authenticate(username,password,mechanism);
if(message.From.Email!=string.Empty) smtp.MailFrom(message.From);
else smtp.MailFrom(message.Sender);
smtp.RcptTo(message.To);
smtp.RcptTo(message.Cc);
smtp.RcptTo(message.Bcc);
smtp.Data(message.ToMimeString());
smtp.Disconnect();
return true;
}
示例3: DirectSend
/// <summary>
/// Sends the message using the specified DNS servers to get mail exchange servers addresses.
/// </summary>
/// <param name="message">The message to be sent.</param>
/// <param name="dnsServers">Servers to be used (in preference order).</param>
/// <example>
/// <code>
/// C#
///
/// Message message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// ServerCollection servers = new ServerCollection();
/// servers.Add("ns1.dnsserver.com",53);
/// servers.Add("ns2.dnsserver.com",53);
///
/// SmtpClient.DirectSend(message,servers);
///
/// VB.NET
///
/// Dim message As New Message
/// message.Subject = "Test"
/// message.From = New Address("[email protected]","John Doe")
/// message.To.Add("[email protected]","Mike Johns")
/// message.BodyText.Text = "Hello this is a test!"
///
/// Dim servers As New ServerCollection
/// servers.Add("ns1.dnsserver.com",53)
/// servers.Add("ns2.dnsserver.com",53)
///
/// SmtpClient.DirectSend(message,servers)
///
/// JScript.NET
///
/// var message:Message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// var servers:ServerCollection = new ServerCollection();
/// servers.Add("ns1.dnsserver.com",53);
/// servers.Add("ns2.dnsserver.com",53);
///
/// SmtpClient.DirectSend(message,servers);
/// </code>
/// </example>
public static string DirectSend(Message message, ServerCollection dnsServers)
{
// Ensure that the mime part tree is built
message.CheckBuiltMimePartTree();
string email = (message.From.Name!="(unknown)") ? message.From.Email : message.Sender.Email;
int recipientCount = message.To.Count+message.Cc.Count+message.Bcc.Count;
#if !PocketPC
System.Array domains = System.Array.CreateInstance(typeof(string),new int[] {recipientCount},new int[] {0});
System.Array adds = System.Array.CreateInstance(typeof(ActiveUp.Net.Mail.Address),new int[] {recipientCount},new int[] {0});
#else
System.Array domains = System.Array.CreateInstance(typeof(string), new int[] { recipientCount });
System.Array adds = System.Array.CreateInstance(typeof(ActiveUp.Net.Mail.Address), new int[] { recipientCount });
#endif
ActiveUp.Net.Mail.AddressCollection recipients = new ActiveUp.Net.Mail.AddressCollection();
recipients += message.To;
recipients += message.Cc;
recipients += message.Bcc;
for(int i=0;i<recipients.Count;i++)
{
if (ActiveUp.Net.Mail.Validator.ValidateSyntax(recipients[i].Email))
{
domains.SetValue(recipients[i].Email.Split('@')[1],i);
adds.SetValue(recipients[i],i);
}
}
System.Array.Sort(domains,adds,null);
string currentDomain = "";
string address = "";
string buf = "";
ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient();
for(int j=0;j<adds.Length;j++)
{
address = ((ActiveUp.Net.Mail.Address)adds.GetValue(j)).Email;
if(((string)domains.GetValue(j))==currentDomain)
{
smtp.RcptTo(address);
if(j==(adds.Length-1))
{
smtp.Data(message.ToMimeString(true));//,(message.Charset!=null ? message.Charset : "iso-8859-1"));
smtp.Disconnect();
}
}
else
{
if(currentDomain!="")
{
smtp.Data(message.ToMimeString(true));//,(message.Charset!=null ? message.Charset : "iso-8859-1"));
smtp.Disconnect();
smtp = new ActiveUp.Net.Mail.SmtpClient();
//.........这里部分代码省略.........
示例4: SendSsl
public bool SendSsl(Message message, string host, int port, string username, string password,
SaslMechanism mechanism, EncryptionType enc_type)
{
// Ensure that the mime part tree is built
message.CheckBuiltMimePartTree();
switch (enc_type)
{
case EncryptionType.SSL:
ConnectSsl(host, port);
break;
case EncryptionType.StartTLS:
ConnectPlain(host, port);
break;
default:
throw new ArgumentException("Incompatible EncriptionType with SendSSL: " + enc_type);
}
SendEhloHelo();
if (enc_type == EncryptionType.StartTLS)
{
StartTLS(host);
}
SendMessageWithAuthentication(username, password, mechanism, message);
return true;
}
示例5: Send
/// <summary>
/// Sends the message using the specified host on the specified port. Secure SASL Authentication is performed according to the requested mechanism.
/// </summary>
/// <param name="message">The message to be sent.</param>
/// <param name="host">The host to be used.</param>
/// <param name="username">The username to be used for authentication.</param>
/// <param name="password">The password to be used for authentication.</param>
/// <param name="mechanism">SASL Mechanism to be used for authentication.</param>
/// <param name="port">The port to be used.</param>
/// <example>
/// <code>
/// C#
///
/// Message message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504);
///
/// VB.NET
///
/// Dim message As New Message
/// message.Subject = "Test"
/// message.From = New Address("[email protected]","John Doe")
/// message.To.Add("[email protected]","Mike Johns")
/// message.BodyText.Text = "Hello this is a test!"
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504)
///
/// JScript.NET
///
/// var message:Message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504);
/// </code>
/// </example>
public bool Send(Message message, string host, int port, string username, string password,
SaslMechanism mechanism)
{
// Ensure that the mime part tree is built
message.CheckBuiltMimePartTree();
ConnectPlain(host, port);
SendEhloHelo();
Authenticate(username, password, mechanism);
if (message.From.Email != string.Empty) MailFrom(message.From);
else MailFrom(message.Sender);
RcptTo(message.To);
RcptTo(message.Cc);
RcptTo(message.Bcc);
Data(message.ToMimeString());
Disconnect();
return true;
}
示例6: Send
/// <summary>
/// Sends the message using the specified host on the specified port. Secure SASL Authentication is performed according to the requested mechanism.
/// </summary>
/// <param name="message">The message to be sent.</param>
/// <param name="host">The host to be used.</param>
/// <param name="username">The username to be used for authentication.</param>
/// <param name="password">The password to be used for authentication.</param>
/// <param name="mechanism">SASL Mechanism to be used for authentication.</param>
/// <param name="port">The port to be used.</param>
/// <example>
/// <code>
/// C#
///
/// Message message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504);
///
/// VB.NET
///
/// Dim message As New Message
/// message.Subject = "Test"
/// message.From = New Address("[email protected]","John Doe")
/// message.To.Add("[email protected]","Mike Johns")
/// message.BodyText.Text = "Hello this is a test!"
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504)
///
/// JScript.NET
///
/// var message:Message = new Message();
/// message.Subject = "Test";
/// message.From = new Address("[email protected]","John Doe");
/// message.To.Add("[email protected]","Mike Johns");
/// message.BodyText.Text = "Hello this is a test!";
///
/// SmtpClient.Send(message,"mail.myhost.com","jdoe1234","tanstaaf",SaslMechanism.CramMd5,8504);
/// </code>
/// </example>
public static bool Send(Message message, string host, int port, string username, string password, SaslMechanism mechanism)
{
// Ensure that the mime part tree is built
message.CheckBuiltMimePartTree();
var smtp = new SmtpClient();
smtp.Connect(host,port);
smtp.SendEhloHelo();
smtp.Authenticate(username, password, mechanism);
if(message.From.Email!=string.Empty) smtp.MailFrom(message.From);
else smtp.MailFrom(message.Sender);
smtp.RcptTo(message.To);
smtp.RcptTo(message.Cc);
smtp.RcptTo(message.Bcc);
smtp.Data(message.ToMimeString());
smtp.Disconnect();
return true;
}
示例7: SendSsl
public static bool SendSsl(Message message, string host, int port, string username, string password, SaslMechanism mechanism)
{
// Ensure that the mime part tree is built
message.CheckBuiltMimePartTree();
ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient();
smtp.ConnectSsl(host, port);
smtp.SendEhloHelo();
SendMessageWithAuthentication(smtp, username, password, mechanism, message);
return true;
}