当前位置: 首页>>代码示例>>C#>>正文


C# MimeKit.MimeMessage类代码示例

本文整理汇总了C#中MimeKit.MimeMessage的典型用法代码示例。如果您正苦于以下问题:C# MimeMessage类的具体用法?C# MimeMessage怎么用?C# MimeMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MimeMessage类属于MimeKit命名空间,在下文中一共展示了MimeMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendEmailAsync

        public async Task SendEmailAsync(string email, string subject, string message)
        {
            var emailMessage = new MimeMessage();

            emailMessage.From.Add(new MailboxAddress(_settings.Value.Author, _settings.Value.Email));
            emailMessage.To.Add(new MailboxAddress("", email));
            emailMessage.Subject = subject;
            emailMessage.Body = new TextPart("html") {Text = message};
            try
            {
                var client = new SmtpClient();
                //     {
                // client.Connect("smtp.gmail.com", 587, SecureSocketOptions.Auto);
                // client.Authenticate(_settings.Value.Email, _settings.Value.Password);
                //  client.Send(emailMessage);
                // client.Disconnect(true);
                await client.ConnectAsync("smtp.gmail.com", 587, SecureSocketOptions.Auto);
                await client.AuthenticateAsync(_settings.Value.Email, _settings.Value.Password);

                await client.SendAsync(emailMessage);
                await client.DisconnectAsync(true);
                //  }
            }
            catch (Exception ex) //todo add another try to send email
            {
                var e = ex;
                throw;
            }
           
        }
开发者ID:parys,项目名称:MyLiverpool,代码行数:30,代码来源:AuthMessageSender.cs

示例2: SendMessage

 public void SendMessage() {
     string msg = "";
     switch (CurrEmailType) {
         case EmailType.PRENOTA:
             msg = PrenotaSubject;
             FromMailAddress = PrenotaFromAddress;
             break;
         case EmailType.INFO:
             msg = InfoSubject;
             FromMailAddress = InfoFromAddress;
             break;
     }
     string subject = string.Format(msg, Message.Nome, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
     string body = string.Format("Nome : {0}\nNumero : {1}\nE-Mail : {2}\nMessaggio :\n{3}", Message.Nome, Message.Telefono, Message.Email, Message.Messaggio);
     var message = new MimeMessage();
     message.From.Add(FromMailAddress);
     message.To.Add(ToAddress);
     message.Subject = subject;
     message.Body = new TextPart("plain") {Text = body};
     try {
         using (var client = new SmtpClient()) {
             client.Connect("smtp.gmail.com", 465, true);
             client.AuthenticationMechanisms.Remove("XOAUTH");
             client.Authenticate("[email protected]", "At066bn1!");
             client.Send(message);
             client.Disconnect(true);
         }
         Result = EmailResult.SUCCESS;
         MessageResult = "Messaggio inviato correttamente";
     } catch (Exception ex) {
         Result = EmailResult.FAIL;
         MessageResult = ex.Message;
     }
 }
开发者ID:LupinIIIit,项目名称:Splendor.Web,代码行数:34,代码来源:EmailService.cs

示例3: SendEmail

 /// <summary>
 /// MAIL KIT
 /// Info : http://dotnetthoughts.net/how-to-send-emails-from-aspnet-core/
 /// </summary>
 public static void SendEmail(string email, string name, string subject, string message,byte[] attachment = null,string attachmentName ="Facture")
 {
     var mimeMessage = new MimeMessage();
     mimeMessage.From.Add(new MailboxAddress(Configurations.Application.StolonsLabel, Configurations.Application.MailAddress));
     mimeMessage.To.Add(new MailboxAddress(name, email));
     mimeMessage.Subject = subject;
     var bodyBuilder = new BodyBuilder();
     if(attachment != null)
         bodyBuilder.Attachments.Add(attachmentName,attachment);
     bodyBuilder.HtmlBody = message;
     mimeMessage.Body = bodyBuilder.ToMessageBody();
     try
     {
         using (var client = new SmtpClient())
         {
             client.Connect(Configurations.Application.MailSmtp, Configurations.Application.MailPort, false);
             client.AuthenticationMechanisms.Remove("XOAUTH2");
             // Note: since we don't have an OAuth2 token, disable
             // the XOAUTH2 authentication mechanism.
             client.Authenticate(Configurations.Application.MailAddress, Configurations.Application.MailPassword);
             client.Send(mimeMessage);
             client.Disconnect(true);
         }
     }
     catch (Exception except)
     {
         Console.WriteLine("Error on sending mail : " + except.Message);
     }
 }
开发者ID:ChavFDG,项目名称:Stolons,代码行数:33,代码来源:MessageServices.cs

示例4: Simple

		public static void Simple ()
		{
			#region Simple
			var message = new MimeMessage ();
			message.From.Add (new MailboxAddress ("Joey", "[email protected]"));
			message.To.Add (new MailboxAddress ("Alice", "[email protected]"));
			message.Subject = "How you doin?";

			var builder = new BodyBuilder ();

			// Set the plain-text version of the message text
			builder.TextBody = @"Hey Alice,

What are you up to this weekend? Monica is throwing one of her parties on
Saturday and I was hoping you could make it.

Will you be my +1?

-- Joey
";

			// We may also want to attach a calendar event for Monica's party...
			builder.Attachments.Add (@"C:\Users\Joey\Documents\party.ics");

			// Now we just need to set the message body and we're done
			message.Body = builder.ToMessageBody ();
			#endregion
		}
开发者ID:jstedfast,项目名称:MailKit,代码行数:28,代码来源:BodyBuilder.cs

示例5: Generic

        public static void Generic(string[] args)
        {
            MainActivity = new MainActivity ();

            var message = new MimeMessage ();
            message.From.Add (new MailboxAddress ("test", "[email protected]"));
            message.To.Add (new MailboxAddress (MainActivity.nome, MainActivity.email));
            message.Subject = "Obrigado por se candidatar";

            message.Body = new TextPart ("plain") {
                Text = @"Obrigado por se candidatar, assim que tivermos uma vaga disponível

            para programador entraremos em contato."

            };

            using (var client = new SmtpClient ()) {
                client.Connect ("smtp.test.com", 587, false);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove ("XOAUTH2");

                // Note: only needed if the SMTP server requires authentication
                client.Authenticate ("test", "password");

                client.Send (message);
                client.Disconnect (true);
            }
        }
开发者ID:jeffersonwagner,项目名称:ApplyForJob,代码行数:30,代码来源:SendEmail.cs

示例6: IsRuleMatching

        public static bool IsRuleMatching(MimeMessage message, Rule rule) {
            var fromAddress = message.From.Cast<MailboxAddress>().First().Address;

            switch (rule.Type) {
                case RuleType.SenderEquals:
                    return fromAddress == rule.Value;

                case RuleType.SenderContains:
                    return fromAddress.Contains(rule.Value);

                case RuleType.SenderEndsWith:
                    return fromAddress.EndsWith(rule.Value);

                case RuleType.SubjectContains:
                    return message.Subject.Contains(rule.Value);

                case RuleType.SubjectEquals:
                    return message.Subject == rule.Value;

                case RuleType.SubjectBeginsWith:
                    return message.Subject.StartsWith(rule.Value);

                case RuleType.SubjectEndsWith:
                    return message.Subject.EndsWith(rule.Value);
            }

            return false;
        }
开发者ID:LinuxDoku,项目名称:ResiLab.MailFilter,代码行数:28,代码来源:RuleMatcher.cs

示例7: MessageViewModel

 public MessageViewModel(MimeMessage message)
 {
     _msg = message;
     var pvm = new PartViewModel(message.Body);
     pvm.IsExpanded = true;
     _main = new[] {pvm};
 }
开发者ID:LiDamon,项目名称:smtp4dev,代码行数:7,代码来源:MessageViewModel.cs

示例8: Should_return_multiple_emails_when_sent

		public async Task Should_return_multiple_emails_when_sent()
		{
		    using (var sut = GetSut())
		    {
		        var msg = new MimeMessage();
		        msg.From.Add(new MailboxAddress("", "[email protected]"));
		        msg.To.Add(new MailboxAddress("", "[email protected]"));
		        msg.Subject = "subject";
		        msg.Body = new TextPart("plain") {Text = "body"};

		        var msg2 = new MimeMessage();
		        msg2.From.Add(new MailboxAddress("", "[email protected]"));
		        msg2.To.Add(new MailboxAddress("", "[email protected]"));
		        msg2.Subject = "subject2";
		        msg2.Body = new TextPart("plain") {Text = "body2"};

		        var emails =
		            (await
		                GetEmails(sut, s => s.GetEmails(), () => SendEmailsAsync(sut, msg), () => SendEmailsAsync(sut, msg2)))
		                .ToList();

		        Assert.That(emails.Count, Is.EqualTo(2));
		        AssertEmailsAreEqual(emails[0], msg2);
		        AssertEmailsAreEqual(emails[1], msg);
		    }
		}
开发者ID:NickLydon,项目名称:SmtpInMemory,代码行数:26,代码来源:ServerTests.cs

示例9: Send

        public void Send(EmailDependencies email)
        {
            try
            {
                var message = new MimeMessage();
                message.From.Add(new MailboxAddress(email.FromName, email.FromAddress));

                message.To.Add(new MailboxAddress(email.ToName, email.ToAddress));
                message.To.Add(new MailboxAddress(email.FromName, email.FromAddress));

                message.Subject = email.Title;
                message.Body = new TextPart("html") { Text = email.content };

                using (var client = new SmtpClient())
                {
                    client.Connect("mail.bizmonger.net", 587, false);

                    // Note: since we don't have an OAuth2 token, disable
                    // the XOAUTH2 authentication mechanism.
                    client.AuthenticationMechanisms.Remove("XOAUTH2");

                    // Note: only needed if the SMTP server requires authentication
                    client.Authenticate(Configuration.ServerEmail, Configuration.Password);

                    client.Send(message);
                    client.Disconnect(true);
                }
            }
            catch (Exception ex)
            {
                var errorMessage = ex.GetBaseException().Message;
                Debug.WriteLine(errorMessage);
            }
        }
开发者ID:bizmonger,项目名称:QuoteBuilder,代码行数:34,代码来源:EmailClient.cs

示例10: Detect

        /// <summary>
        /// detects whether a message is a qmail (QSBMF) bounce message.
        /// </summary>
        ///
        /// See The qmail-send Bounce Message Format (QSBMF):
        ///      http://cr.yp.to/proto/qsbmf.txt
        public static BounceDetectResult Detect(MimeMessage message)
        {
            //
            // detect on a text part.

            var textPart = message.Body as TextPart;

            if (textPart != null)
            {
                var result = DetectQmailBounce(message, textPart);

                if (result != null)
                    return result;
            }

            //
            // detect on a multipart.

            var multipart = message.Body as MultipartAlternative;

            return multipart?
                .OfType<TextPart>()
                .Select(p => DetectQmailBounce(message, p))
                .FirstOrDefault();
        }
开发者ID:rgl,项目名称:MailBounceDetector,代码行数:31,代码来源:QmailBounceDetector.cs

示例11: EnviarAltaCuenta

 public void EnviarAltaCuenta(string cuentaUsuario, string password)
 {
     var mensage = new MimeMessage();
     mensage.From.Add(new MailboxAddress("Verum In Sanguine", "[email protected]"));
     mensage.To.Add(new MailboxAddress(cuentaUsuario, cuentaUsuario));
     mensage.Subject = "Cuenta de usuario en Verum In Sanguine";
     mensage.Body = new TextPart("html") { Text = TextoAltaCuenta(cuentaUsuario, password) };
     EnviarMensaje(mensage);                       
 }
开发者ID:herruzojm,项目名称:Cronica,代码行数:9,代码来源:ServicioEmail.cs

示例12: AnalyzeMessage

        private static void AnalyzeMessage(MimeMessage message, LearningDataSet result) {
            result.Adresses.AddOrIgnore(message?.Sender?.Address);
            result.Subjects.AddOrIgnore(message?.Subject);

            var urls = UrlParser.Parse(message?.TextBody);
            foreach (var url in urls) {
                result.Urls.AddOrIgnore(url);
            }
        }
开发者ID:LinuxDoku,项目名称:ResiLab.MailFilter,代码行数:9,代码来源:MailBoxFolderAnalyzer.cs

示例13: SendAsync

 public async Task SendAsync(IdentityMessage message)
 {
     var mimeMessage = new MimeMessage();
     mimeMessage.From.Add(new MailboxAddress("Richard Benson", "[email protected]"));
     mimeMessage.To.Add(new MailboxAddress(message.Destination, message.Destination));
     mimeMessage.Subject = message.Subject;
     mimeMessage.Body = new TextPart("plain") { Text = message.Body };
     await _mailSender.SendMailAsync(mimeMessage);
 }
开发者ID:finsaspa,项目名称:Caravan,代码行数:9,代码来源:CaravanEmailService.cs

示例14: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			webView.ScalesPageToFit = true;
			
			// Perform any additional setup after loading the view, typically from a nib.
			Message = MimeMessage.Load (GetType ().Assembly.GetManifestResourceStream ("xamarin3.msg"));
		}
开发者ID:cybercircuits,项目名称:MimeKit,代码行数:9,代码来源:MessageReaderViewController.cs

示例15: MessageSentEventArgs

		/// <summary>
		/// Initializes a new instance of the <see cref="MailKit.MessageSentEventArgs"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new <see cref="MessageSentEventArgs"/>.
		/// </remarks>
		/// <param name="message">The message that was just sent.</param>
		/// <param name="response">The response from the server.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <para><paramref name="message"/> is <c>null</c>.</para>
		/// <para>-or-</para>
		/// <para><paramref name="response"/> is <c>null</c>.</para>
		/// </exception>
		public MessageSentEventArgs (MimeMessage message, string response)
		{
			if (message == null)
				throw new ArgumentNullException (nameof (message));

			if (response == null)
				throw new ArgumentNullException (nameof (response));

			Message = message;
			Response = response;
		}
开发者ID:jstedfast,项目名称:MailKit,代码行数:24,代码来源:MessageSentEventArgs.cs


注:本文中的MimeKit.MimeMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。