Esempio n. 1
0
        private void SendMessage(AbstractMailMessage msg, SendCompletedEventHandler onSendCallBack)
        {
            // Connecting to the server and configuring it
            using (var client = new MimeMailer())
            {
                client.Host = _host;
                client.Port = _port;
                ((SmtpSocketClient)client).SslType = _ssl;
                if (String.IsNullOrEmpty(_userName))
                {
                    client.AuthenticationMode = AuthenticationType.UseDefualtCridentials;
                }
                else
                {
                    client.Password = _passWord;
                    // Provide your credentials
                    client.User = _userName;
                }

                client.SslType = _implictSsl;
                // Use SendAsync to send the message asynchronously
                //    client.Send(msg);
                client.SendCompleted += onSendCallBack;
                // The userState can be any object that allows your callback
                // method to identify this send operation.
                // For this example, the userToken is a string constant.
                client.SendMailAsync(msg);
            }
        }
Esempio n. 2
0
        public void SendImplicitMail(List <MailAddress> recieverMailAddresses, MailPriority messagePriority, string messageSubject, string messageBody, List <string> attachmentAddress = null, List <MailAddress> ccMailAddresses = null, List <MailAddress> bccMailAddresses = null)
        {
            var msg = new MimeMailMessage
            {
                From       = new MailAddress(_senderEmailAddresss, _senderDisplayName),
                Subject    = messageSubject,
                Body       = messageBody,
                IsBodyHtml = _useHtml
            };

            recieverMailAddresses.ForEach(a => msg.To.Add(a));
            if (ccMailAddresses != null)
            {
                ccMailAddresses.ForEach(a => msg.To.Add(a));
            }
            if (bccMailAddresses != null)
            {
                bccMailAddresses.ForEach(a => msg.To.Add(a));
            }

            if (attachmentAddress != null)
            {
                attachmentAddress.ForEach(a => msg.Attachments.Add(new MimeAttachment(a)));
            }

            var mm = new MimeMailer(_host, _port, _userName, _passWord, _ssl, _authenticationType);

            mm.Send(msg, _onSendCallBack);
        }