예제 #1
0
		internal MimePartCollection ConcatMessagesAsPart(MessageCollection input)
		{
			MimePartCollection output = new MimePartCollection();
			foreach(MimePart part in this) output.Add(part);
			foreach(Message message in input) output.Add(message.ToMimePart());
            return output;			
		}
        private void _bRetrieveMessageList_Click(object sender, EventArgs e)
        {
            // We create Imap client
            Imap4Client imap = new Imap4Client();

            try
            {
                // We connect to the imap4 server
                imap.Connect(_tbImap4Server.Text);

                this.AddLogEntry(string.Format("Connection to {0} successfully", _tbImap4Server.Text));

                // Login to mail box
                imap.Login(_tbUserName.Text, _tbPassword.Text);

                this.AddLogEntry(string.Format("Login to {0} successfully", _tbImap4Server.Text));

                Mailbox inbox = imap.SelectMailbox("inbox");

                MessageCollection mc = new MessageCollection();

                for (int n = 1; n < inbox.MessageCount + 1; n++)
                {
                    ActiveUp.Net.Mail.Message newMessage = inbox.Fetch.MessageObject(n);
                    mc.Add(newMessage);
                    this.AddLogEntry(string.Format("Message ({0}) : {1}", n.ToString(), newMessage.Subject));
                }
                
            }

            catch (Imap4Exception iex)
            {
                this.AddLogEntry(string.Format("Imap4 Error: {0}", iex.Message));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }

            finally
            {
                if (imap.IsConnected)
                {
                    imap.Disconnect();
                }
            }
        }
예제 #3
0
        private void _bRetrieveMessageList_Click(object sender, EventArgs e)
        {
            // We create nntp client object.
            NntpClient nntp = new NntpClient();

            try
            {
                // We connect to the nntp server.
                nntp.Connect(_tbNntpServer.Text);
                
                // Get a news group on the server
                NewsGroup group = nntp.SelectGroup(_tbNewsgroup.Text);

                //Retrive the article and display the subject

                MessageCollection mc = new MessageCollection();
                for (int n = 0; n < group.ArticleCount; n++)
                {
                    ActiveUp.Net.Mail.Message message = group.RetrieveArticleObject(n);
                    mc.Add(message);

                    this.AddLogEntry(string.Format("Subject : {0}",message.Subject));
                }

                //mc will contain the list of messages      
            }

            catch (NntpException pexp)
            {
                this.AddLogEntry(string.Format("Nntp Error: {0}", pexp.Message));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }

            finally
            {
                if (nntp.IsConnected)
                {
                    nntp.Disconnect(); ;
                }
            }
        }
        private void _bRetrieveMessageList_Click(object sender, EventArgs e)
        {
            // We instantiate the pop3 client.
            Pop3Client pop = new Pop3Client();

            try
            {
                this.AddLogEntry(string.Format("Connection to the pop 3 server : {0}", _tbPop3Server.Text));

                // Connect to the pop3 client
                pop.Connect(_tbPop3Server.Text, _tbUserName.Text, _tbPassword.Text);

                this.AddLogEntry("Retrieve message list");

                MessageCollection mc = new MessageCollection();
                for (int n = 1; n < pop.MessageCount + 1; n++)
                {
                    Message newMessage = pop.RetrieveMessageObject(n);
                    mc.Add(newMessage);

                    this.AddLogEntry(string.Format("Message ({0}) : {1}",n.ToString(),newMessage.Subject));
                }

            }

            catch (Pop3Exception pexp)
            {
                this.AddLogEntry(string.Format("Pop3 Error: {0}", pexp.Message));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }

            finally
            {
                if (pop.IsConnected)
                {
                    pop.Disconnect();
                }
            }
        }
예제 #5
0
                    /// <summary>
		            /// Sends all messages using the specified host and port.
		            /// </summary>
		            /// <param name="messages">The message collection to be sent.</param>
		            /// <param name="host">Address of the server to be used.</param>
		            /// <param name="port">Port to be used.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com",8504);
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com",8504)
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com",8504);
		            /// </code>
		            /// </example>
                    public static int SendCollection(MessageCollection messages, string host, int port)
		            {
                        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());
			            }
			            int sent=0;
			            foreach(Message message in messages)
			            {
				            try
				            {
                                // Ensure that the mime part tree is built
                                message.CheckBuiltMimePartTree();

					            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());
					            sent++;
				            }
				            catch(ActiveUp.Net.Mail.SmtpException) { }
			            }
			            smtp.Disconnect();
			            return sent;
		            }
예제 #6
0
 public static IAsyncResult BeginSendCollection(MessageCollection messages, ServerCollection servers, ref SmtpExceptionCollection errors, AsyncCallback callback)
 {
     SmtpClient._delegateSendMessageCollectionServerCollectionSmtpExceptionCollection = SmtpClient.SendCollection;
     return SmtpClient._delegateSendMessageCollectionServerCollectionSmtpExceptionCollection.BeginInvoke(messages, servers, ref errors, callback, SmtpClient._delegateSendMessageCollectionServerCollectionSmtpExceptionCollection);
 }
예제 #7
0
                    /// <summary>
		            /// Sends all messages using the specified host.
		            /// </summary>
		            /// <param name="servers">Servers to be used to send the message (in preference order).</param>
		            /// <param name="messages">MessageCollection to be sent.</param>
		            /// <param name="errors">Reference to SmtpException object collection where errors occuring during the process will be stored.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// ServerCollection servers = new ServerCollection();
		            /// servers.Add("mail.myhost.com",25);
		            /// servers.Add("mail2.myhost.com",25);
		            /// 
		            /// SmtpClient.Send(messages,servers,myErrorCollection);
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// Dim servers As New ServerCollection
		            /// servers.Add("mail.myhost.com",25)
		            /// servers.Add("mail2.myhost.com",25)
		            /// 
		            /// SmtpClient.Send(messages,servers,myErrorCollection)
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// var servers:ServerCollection = new ServerCollection();
		            /// servers.Add("mail.myhost.com",25);
		            /// servers.Add("mail2.myhost.com",25);
		            /// 
		            /// SmtpClient.Send(messages,servers,myErrorCollection);
		            /// </code>
		            /// </example>
		            public static int SendCollection(MessageCollection messages, ServerCollection servers, ref SmtpExceptionCollection errors)
		            {
                        ActiveUp.Net.Mail.SmtpClient smtp = new ActiveUp.Net.Mail.SmtpClient();
			            int sent=0;
			            foreach(Message message in messages)
			            {
                            try
				            {
                                // Ensure that the mime part tree is built
                                message.CheckBuiltMimePartTree();

					            for(int i=0;i<servers.Count;i++)
					            {
						            try
                                    {
                                        if (servers[i].ServerEncryptionType != EncryptionType.None)
                                        {
#if !PocketPC
                                            smtp.ConnectSsl(servers[i].Host, servers[i].Port);
#else
                                            smtp.Connect(servers[i].Host, servers[i].Port);
#endif
                                        }
                                        else
                                        {
                                            smtp.Connect(servers[i].Host, servers[i].Port);
                                        }
							            try
							            {
								            smtp.Ehlo(System.Net.Dns.GetHostName());
							            }
							            catch
							            {
								            smtp.Helo(System.Net.Dns.GetHostName());
							            }
							            if(servers[i].Username!=null && servers[i].Username.Length>0 && servers[i].Password!=null && servers[i].Password.Length>0) smtp.Authenticate(servers[i].Username,servers[i].Password,SaslMechanism.Login);
							            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();
							            sent++;
							            break;
						            }
						            catch
						            {
							            continue;
						            }
					            }
				            }
				            catch(ActiveUp.Net.Mail.SmtpException ex) { errors.Add(ex); }
			            }
			            return sent;
		            }
예제 #8
0
		            /// <summary>
		            /// Sends all messages using the specified host.
		            /// </summary>
		            /// <param name="host">Address of the server to be used.</param>
		            /// <param name="errors">Reference to SmtpException object collection where errors occuring during the process will be stored.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com",myErrorCollection);
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com",myErrorCollection)
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com",myErrorCollection);
		            /// </code>
		            /// </example>
		            public static int SendCollection(MessageCollection messages, string host, ref SmtpExceptionCollection errors)
		            {
			            return ActiveUp.Net.Mail.SmtpClient.SendCollection(messages,host,25,ref errors);
		            }
예제 #9
0
 public static IAsyncResult BeginSendCollection(MessageCollection messages, string host, int port, string username, string password, SaslMechanism mechanism, ref SmtpExceptionCollection errors, AsyncCallback callback)
 {
     SmtpClient._delegateSendMessageCollectionStringIntStringStringSaslMechanismSmtpExceptionCollection = SmtpClient.SendCollection;
     return SmtpClient._delegateSendMessageCollectionStringIntStringStringSaslMechanismSmtpExceptionCollection.BeginInvoke(messages, host, port, username, password, mechanism, ref errors, callback, SmtpClient._delegateSendMessageCollectionStringIntStringStringSaslMechanismSmtpExceptionCollection);
 }
예제 #10
0
 public static IAsyncResult BeginDirectSendCollection(MessageCollection messages, string dnsHost, AsyncCallback callback)
 {
     SmtpClient._delegateDirectSendMessageCollectionString = SmtpClient.DirectSendCollection;
     return SmtpClient._delegateDirectSendMessageCollectionString.BeginInvoke(messages, dnsHost, callback, SmtpClient._delegateDirectSendMessageCollectionString);
 }
예제 #11
0
 public static IAsyncResult BeginSendCollection(MessageCollection messages, string host, string username, string password, SaslMechanism mechanism, AsyncCallback callback)
 {
     SmtpClient._delegateSendMessageCollectionStringStringStringSaslMechanism = SmtpClient.SendCollection;
     return SmtpClient._delegateSendMessageCollectionStringStringStringSaslMechanism.BeginInvoke(messages, host, username, password, mechanism, callback, SmtpClient._delegateSendMessageCollectionStringStringStringSaslMechanism);
 }
예제 #12
0
		            /// <summary>
		            /// Sends all messages using the specified host and port as the dns server.
		            /// </summary>
		            /// <param name="messages">The message collection to be sent.</param>
		            /// <param name="dnsHost">Address of the server to be used.</param>
		            /// <param name="dnsPort">Port to be used.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.DirectSend(messages,"ns1.dnsserver.com",53);
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// SmtpClient.DirectSend(messages,"ns1.dnsserver.com",53)
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.DirectSend(messages,"ns1.dnsserver.com",53);
		            /// </code>
		            /// </example>
		            public static int DirectSendCollection(MessageCollection messages, string dnsHost, int dnsPort)
		            {
			            ActiveUp.Net.Mail.ServerCollection servers = new ActiveUp.Net.Mail.ServerCollection();
			            servers.Add(dnsHost, dnsPort);
			            return DirectSendCollection(messages, servers);
		            }
예제 #13
0
		            /// <summary>
		            /// Sends all messages using the specified host as the dns server.
		            /// </summary>
		            /// <param name="messages">The message collection to be sent.</param>
		            /// <param name="dnsHost">Address of the server to be used.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.DirectSend(messages,"ns1.dnsserver.com");
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// SmtpClient.DirectSend(messages,"ns1.dnsserver.com")
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.DirectSend(messages,"ns1.dnsserver.com");
		            /// </code>
		            /// </example>
		            public static int DirectSendCollection(MessageCollection messages, string dnsHost)
		            {
			            return DirectSendCollection(messages, dnsHost, 53);
		            }
예제 #14
0
 public static IAsyncResult BeginDirectSendCollection(MessageCollection messages, ServerCollection dnsServers, AsyncCallback callback)
 {
     SmtpClient._delegateDirectSendMessageCollectionServerCollection = SmtpClient.DirectSendCollection;
     return SmtpClient._delegateDirectSendMessageCollectionServerCollection.BeginInvoke(messages, dnsServers, callback, SmtpClient._delegateDirectSendMessageCollectionServerCollection);
 }
예제 #15
0
		            /// <summary>
		            /// Sends all messages using the specified host as the DNS server.
		            /// </summary>
		            /// <param name="dnsServers">Servers to be used to send the message (in preference order).</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// ServerCollection servers = new ServerCollection();
		            /// servers.Add("ns1.dnsserver.com",53);
		            /// servers.Add("ns2.dnsserver.com",53);
		            /// 
		            /// SmtpClient.DirectSend(messages,servers);
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// Dim servers As New ServerCollection
		            /// servers.Add("ns1.dnsserver.com",53)
		            /// servers.Add("ns2.dnsserver.com",53)
		            /// 
		            /// SmtpClient.DirectSend(messages,servers)
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// var servers:ServerCollection = new ServerCollection();
		            /// servers.Add("ns1.dnsserver.com",53);
		            /// servers.Add("ns2.dnsserver.com",53);
		            /// 
		            /// SmtpClient.DirectSend(messages,servers);
		            /// </code>
		            /// </example>
		            public static int DirectSendCollection(MessageCollection messages, ServerCollection dnsServers)
		            {
			            int sent=0;
			            foreach(ActiveUp.Net.Mail.Message message in messages)
			            {
				            ActiveUp.Net.Mail.SmtpClient.DirectSend(message);
				            sent++;
			            }
			            return sent;
		            }
예제 #16
0
                    /// <summary>
		            /// Sends each message using the DirectMailing technique (SMTP connection with every recipient's mail exchange server for delivery).
		            /// MX Records are cached for faster operation.
		            /// </summary>
		            /// <param name="messages">The message collection to be sent.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.DirectSend(messages);
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// SmtpClient.DirectSend(messages)
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.DirectSend(messages);
		            /// </code>
		            /// </example>
		            public static int DirectSendCollection(MessageCollection messages)
		            {
                        return DirectSendCollection(messages, new ServerCollection());
		            }
예제 #17
0
 public static IAsyncResult BeginSendCollection(MessageCollection messages, string host, int port, AsyncCallback callback)
 {
     SmtpClient._delegateSendMessageCollectionStringInt = SmtpClient.SendCollection;
     return SmtpClient._delegateSendMessageCollectionStringInt.BeginInvoke(messages, host, port, callback, SmtpClient._delegateSendMessageCollectionStringInt);
 }
예제 #18
0
		            /// <summary>
                    /// Sends each message using the DirectMailing technique (SMTP connection with every recipient's mail exchange server for delivery).
                    /// MX Records are cached for faster operation. Errors occuring during the process are catched and stored in a user-defined collection for review at a later time.
                    /// </summary>
                    /// <param name="messages">The message collection to be sent.</param>
                    /// <param name="errors">Reference to an SmtpException Collection to be filled with errors occuring during this process.</param>
                    /// <returns>Amount of messages successfully sent.</returns>
                    /// <example>
                    /// <code>
                    /// C#
                    /// 
                    /// Message message = new Message();
                    /// message.Subject = "Test";
                    /// message.From = new Address("*****@*****.**","John Doe");
                    /// message.To.Add("*****@*****.**","Mike Johns");
                    /// message.BodyText.Text = "Hello this is a test!";
                    /// 
                    /// Message message1 = new Message();
                    /// message1.Subject = "Hey David!";
                    /// message1.From = New Address("*****@*****.**","John Doe");
                    /// message1.To.Add("*****@*****.**","David Clark");
                    /// message1.BodyText.Text = "How you doing ?";
                    /// 
                    /// MessageCollection messages = new MessageCollection();
                    /// messages.Add(message);
                    /// messages.Add(message1);
                    /// 
                    /// SmtpClient.Send(messages,myErrorCollection);
                    /// 
                    /// VB.NET
                    /// 
                    /// Dim message As New Message
                    /// message.Subject = "Test"
                    /// message.From = New Address("*****@*****.**","John Doe")
                    /// message.To.Add("*****@*****.**","Mike Johns")
                    /// message.BodyText.Text = "Hello this is a test!"
                    /// 
                    /// Dim message1 As New Message
                    /// message1.Subject = "Hey David!"
                    /// message1.From = New Address("*****@*****.**","John Doe")
                    /// message1.To.Add("*****@*****.**","David Clark")
                    /// message1.BodyText.Text = "How you doing ?"
                    /// 
                    /// Dim messages As New MessageCollection
                    /// messages.Add(message)
                    /// messages.Add(message1)
                    /// 
                    /// SmtpClient.Send(messages,myErrorCollection)
                    /// 
                    /// JScript.NET
                    /// 
                    /// var message:Message = new Message();
                    /// message.Subject = "Test";
                    /// message.From = new Address("*****@*****.**","John Doe");
                    /// message.To.Add("*****@*****.**","Mike Johns");
                    /// message.BodyText.Text = "Hello this is a test!";
                    /// 
                    /// var message1:Message = new Message();
                    /// message1.Subject = "Hey David!";
                    /// message1.From = New Address("*****@*****.**","John Doe");
                    /// message1.To.Add("*****@*****.**","David Clark");
                    /// message1.BodyText.Text = "How you doing ?";
                    /// 
                    /// var messages:MessageCollection = new MessageCollection();
                    /// messages.Add(message);
                    /// messages.Add(message1);
                    /// 
                    /// SmtpClient.Send(messages,myErrorCollection);
                    /// </code>
                    /// </example>
                    public static int DirectSendCollection(MessageCollection messages, ref SmtpExceptionCollection errors)
                    {
                        int sent = 0;
                        foreach (ActiveUp.Net.Mail.Message message in messages)
                        {
                            try
                            {
                                ActiveUp.Net.Mail.SmtpClient.DirectSend(message);
                                sent++;
                            }
                            catch (ActiveUp.Net.Mail.SmtpException ex) { errors.Add(ex); }
                        }
                        return sent;
                    }
예제 #19
0
 public static IAsyncResult BeginSendCollection(MessageCollection messages, string host, int port, ref SmtpExceptionCollection errors, AsyncCallback callback)
 {
     SmtpClient._delegateSendMessageCollectionStringIntSmtpExceptionCollection = SmtpClient.SendCollection;
     return SmtpClient._delegateSendMessageCollectionStringIntSmtpExceptionCollection.BeginInvoke(messages, host, port, ref errors, callback, SmtpClient._delegateSendMessageCollectionStringIntSmtpExceptionCollection);
 }
예제 #20
0
 /// <summary>
 /// Search for messages accoridng to the given query.
 /// </summary>
 /// <param name="query">Query to use.</param>
 /// <returns>A collection of messages matching the query.</returns>
 /// <example>
 /// <code>
 /// C#
 ///  
 /// Imap4Client imap = new Imap4Client();
 /// imap.Connect("mail.myhost.com");
 /// imap.Login("jdoe1234","tanstaaf");
 /// Mailbox inbox = imap.SelectInbox("inbox");
 /// MessageCollection messages = inbox.SearchParse("SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith");
 /// imap.Disconnect();
 /// 
 /// VB.NET
 ///  
 /// Dim imap As New Imap4Client
 /// imap.Connect("mail.myhost.com")
 /// imap.Login("jdoe1234","tanstaaf")
 /// Dim inbox As Mailbox = imap.SelectInbox("inbox")
 /// Dim messages As MessageCollection = inbox.SearchParse("SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith")
 /// imap.Disconnect()
 /// 
 /// JScript.NET
 ///  
 /// var imap:Imap4Client imap = new Imap4Client();
 /// imap.Connect("mail.myhost.com");
 /// imap.Login("jdoe1234","tanstaaf");
 /// var inbox:Mailbox = imap.SelectInbox("inbox");
 /// var messages:MessageCollection = inbox.SearchParse("SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith");
 /// imap.Disconnect();
 /// </code>
 /// </example>
 public MessageCollection SearchParse(string query)
 {
     ActiveUp.Net.Mail.MessageCollection msgs = new ActiveUp.Net.Mail.MessageCollection();
     foreach(int i in this.Search(query)) msgs.Add(this.Fetch.MessageObject(i));
     return msgs;
 }
예제 #21
0
                    /// <summary>
		            /// Sends the message using the specified host and port after authentication.
		            /// </summary>
		            /// <param name="messages">The message collection to be sent.</param>
		            /// <param name="host">Host to be used to send the message.</param>
		            /// <param name="username">Username to be used for the authentication process.</param>
		            /// <param name="password">Password to be used for the authentication process.</param>
		            /// <param name="mechanism">SASL mechanism to be used.</param>
		            /// <param name="port">Port to be used to connect to the specified host.</param>
		            /// <param name="errors">Reference to SmtpException object collection where errors occuring during the process will be stored.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
                    public static int SendCollection(MessageCollection messages, string host, int port, string username, string password, SaslMechanism mechanism, ref SmtpExceptionCollection errors)
		            {
			            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);
			            int sent = 0;
			            foreach(Message message in messages)
			            {
				            try
				            {
                                // Ensure that the mime part tree is built
                                message.CheckBuiltMimePartTree();

					            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());
					            sent++;
				            }
				            catch(ActiveUp.Net.Mail.SmtpException ex) { errors.Add(ex); }
			            }
			            smtp.Disconnect();
			            return sent;
                    }
예제 #22
0
		/// <summary>
		/// Create a collection of message based on the merging of the message and a datasource.
		/// </summary>
		/// <param name="message">The message to use as a base for merging.</param>
		/// <param name="dataSource">The datasource to use for merging.</param>
		/// <param name="send">Specify if you want to send the message when merged.</param>
		/// <returns>The merged MessageCollection.</returns>
		public MessageCollection MergeCollection(Message message, object dataSource, bool send)
		{
			MessageCollection messages = new MessageCollection();

			if (dataSource.GetType().ToString() == "System.Data.DataSet")
				dataSource = ((System.Data.DataSet)dataSource).Tables[0];

			IEnumerator items = GetEnumerator(dataSource);

			// Determine max
			int total = 0;//, messageNumber = 0, messageSent = 0;

			while(items.MoveNext())
				total++;

			items.Reset();
		
			if (items != null)
			{
				while(items.MoveNext())
				{
					Message newMessage = message.Clone();
					this.MergeMessage(newMessage, items.Current);
					messages.Add(newMessage);

					/*string file = @"c:\temp\_amail_\test.eml";
					if (File.Exists(file))
						File.Delete(file);
					newMessage.StoreToFile(file);*/

					if (send)
					{
                        if (this.SmtpServers.Count > 0)
                        {
                            //newMessage.Send(this.SmtpServers);
                            SmtpClient.Send(newMessage, this.SmtpServers);
                        }
                        else
                        {
                            //newMessage.DirectSend();
                            SmtpClient.DirectSend(newMessage);
                        }
					}
				}

				ActiveUp.Net.Mail.Logger.AddEntry("Message created successfully.", 2);
			}

			return messages;
		}
예제 #23
0
 public static IAsyncResult BeginSendQueued(MessageCollection messages, string spoolDirectory, QueuingService queuingService, AsyncCallback callback)
 {
     SmtpClient._delegateSendQueuedMessageCollection = SmtpClient.SendQueued;
     return SmtpClient._delegateSendQueuedMessageCollection.BeginInvoke(messages, spoolDirectory, queuingService, callback, SmtpClient._delegateSendQueuedMessageCollection);
 }
예제 #24
0
 /// <summary>
 /// Search for messages accoridng to the given query.
 /// </summary>
 /// <param name="query">Query to use.</param>
 /// <param name="charset">The charset to apply the query for.</param>
 /// <returns>A collection of messages matching the query.</returns>
 public MessageCollection SearchParse(string charset, string query)
 {
     MessageCollection msgs = new MessageCollection();
     foreach(int i in this.Search(charset,query)) msgs.Add(this.Fetch.MessageObject(i));
     return msgs;
 }
예제 #25
0
                    /// <summary>
		            /// Sends all messages using the specified host.
		            /// </summary>
		            /// <param name="host">Address of the server to be used.</param>
		            /// <returns>Amount of messages successfully sent.</returns>
		            /// <example>
		            /// <code>
		            /// C#
		            /// 
		            /// Message message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// Message message1 = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// MessageCollection messages = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com");
		            /// 
		            /// VB.NET
		            /// 
		            /// Dim message As New Message
		            /// message.Subject = "Test"
		            /// message.From = New Address("*****@*****.**","John Doe")
		            /// message.To.Add("*****@*****.**","Mike Johns")
		            /// message.BodyText.Text = "Hello this is a test!"
		            /// 
		            /// Dim message1 As New Message
		            /// message1.Subject = "Hey David!"
		            /// message1.From = New Address("*****@*****.**","John Doe")
		            /// message1.To.Add("*****@*****.**","David Clark")
		            /// message1.BodyText.Text = "How you doing ?"
		            /// 
		            /// Dim messages As New MessageCollection
		            /// messages.Add(message)
		            /// messages.Add(message1)
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com")
		            /// 
		            /// JScript.NET
		            /// 
		            /// var message:Message = new Message();
		            /// message.Subject = "Test";
		            /// message.From = new Address("*****@*****.**","John Doe");
		            /// message.To.Add("*****@*****.**","Mike Johns");
		            /// message.BodyText.Text = "Hello this is a test!";
		            /// 
		            /// var message1:Message = new Message();
		            /// message1.Subject = "Hey David!";
		            /// message1.From = New Address("*****@*****.**","John Doe");
		            /// message1.To.Add("*****@*****.**","David Clark");
		            /// message1.BodyText.Text = "How you doing ?";
		            /// 
		            /// var messages:MessageCollection = new MessageCollection();
		            /// messages.Add(message);
		            /// messages.Add(message1);
		            /// 
		            /// SmtpClient.Send(messages,"mail.myhost.com");
		            /// </code>
		            /// </example>
		            public static int SendCollection(MessageCollection messages, string host)
		            {
			            return SendCollection(messages,host,25);
		            }
예제 #26
0
파일: Form1.cs 프로젝트: ghy/EmailSimple
        private void btnReceive_Click(object sender, EventArgs e)
        {
            this.listBox1.Items.Clear();
            // We instantiate the pop3 client.
            Pop3Client pop3Client = new Pop3Client();

            string server = this.txtPopServer.Text;
            string username = txtEmail.Text;
            string password = txtPassword.Text;
            int popPort = Convert.ToInt32(txtPopPort.Text);

            try
            {

                // pop3Client.APOPConnect(server, popPort, username, password);

                pop3Client.Connect(server, popPort, username, password);
                //   pop3Client.Authenticate(username, password, SaslMechanism.CramMd5);

                int count = pop3Client.MessageCount;

                this.AddLogEntry(string.Format("共收到{0}封 :", count));

                MessageCollection mc = new MessageCollection();

                //ActiveUp.Net.Mail.Message newMessage = pop.RetrieveMessageObject(count);
                //mc.Add(newMessage);
                // this.AddLogEntry(string.Format("Message ({0}) : {1}", count.ToString(), newMessage.Subject));

                //for (int n = count; n >= 1; n--)
                //{
                //    var msg = pop.RetrieveMessageObject(n);
                //    this.AddLogEntry(string.Format("{0}-({1}) : {2}", n.ToString(), msg.Date.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), msg.Subject));
                //}

                string str = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                DateTime d;
                DateTime.TryParse(str, out d);

                var date = DateTime.Now.AddDays(-6);

                while (count > 0)
                {
                    var msg = pop3Client.RetrieveMessageObject(count);

                    if (msg.Date.ToLocalTime() < date)
                        break;
                    var subject = msg.Subject;

                    if (subject.Contains("问题回复-【") && subject.Contains("【") && subject.Contains("】"))
                    {
                        var index = subject.IndexOf("【") + 1;
                        var issueNo = subject.Substring(index, subject.IndexOf("】") - index);
                    }

                    this.AddLogEntry(string.Format("{0}-({1}) : {2}", count.ToString(), msg.Date.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), msg.Subject));
                    count--;
                }

            }
            catch (Pop3Exception pexp)
            {
                this.AddLogEntry(string.Format("Pop3 Error: {0}", pexp.Message));
            }
            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }

            finally
            {
                if (pop3Client.IsConnected)
                {
                    pop3Client.Disconnect();
                }
            }
        }