private static IEnumerable <MyEnvelope> GetBatchFromKafka() { //Fake Kafka consumer message generator var messages = new List <MyEnvelope>(); var rnd = new Random(); for (int i = 0; i < 50; i++) { var message = new MyEnvelope { DeviceId = rnd.Next(1, 1000).ToString(), SomeMessage = new SomeMessage { Data = Guid.NewGuid().ToString() } }; messages.Add(message); var message2 = new MyEnvelope { DeviceId = rnd.Next(1, 1000).ToString(), SomeOtherMessage = new SomeOtherMessage { IntProperty = rnd.Next(1, 100000) } }; messages.Add(message2); } return(messages); }
public void Envelope(string body, string to, string subject, string toName) { var envelope = new MyEnvelope(); envelope.password = _connections.Email.password; envelope.body = "<b>Testing: </b> <span style=\"color:red;\">The mailkit system.</span>"; envelope.fromAddress = _connections.Email.email; envelope.fromName = "Beyond Logical"; envelope.port = _connections.Email.port; envelope.smtp = _connections.Email.smtp; envelope.subject = "Final - Test email from myself to myself - Final"; envelope.toAddress = "*****@*****.**"; envelope.toName = "JP Piesco"; envelope.username = _connections.Email.email; //Send(envelope); }
public string Get(int id) { var envelope = new MyEnvelope(); envelope.password = "******"; envelope.body = "<b>Testing: </b> <span style=\"color:red;\">The mailkit system.</span>"; envelope.fromAddress = "*****@*****.**"; envelope.fromName = "Beyond Logical"; envelope.port = 587; envelope.smtp = "mail.mysite.com"; envelope.subject = "Final - Test email from myself to myself - Final"; envelope.toAddress = "*****@*****.**"; envelope.toName = "Bryan Maveric"; envelope.username = "******"; Send(envelope); return("value"); }
public void Send(MyEnvelope envelope) { var message = new MimeMessage(); message.From.Add(new MailboxAddress(envelope.fromName, envelope.fromAddress)); message.To.Add(new MailboxAddress(envelope.toName, envelope.toAddress)); message.Subject = envelope.subject; message.Body = new TextPart("html") { Text = envelope.body }; using (var client = new SmtpClient()) { client.Connect(envelope.smtp, envelope.port); client.Authenticate(envelope.username, envelope.password); client.Send(message); client.Disconnect(true); } }