
Connect to DB2 in Java – Solved
Connect to DB2 in Java – Solved A solved example of how to connect to the db2 database in Java, run a query and retrieve its results. Then traverse through …
Read MoreFind simple answers to your complex questions
Connect to DB2 in Java – Solved A solved example of how to connect to the db2 database in Java, run a query and retrieve its results. Then traverse through …
Read MoreIntersection of Two Arrays in JavaScript – Solved As the site name suggests I’m going to keep it simple. If your objective is to take an intersection of two arrays, …
Read Moregpio.in – RuntimeError: no access to dev/mem – Solved Run the following commands:
1 2 |
sudo rpi-update |
to make sure you are using a recent kernel, and
1 2 3 4 |
sudo apt-get update sudo apt-get upgrade |
Add the PI user to …
Read MoreTypeError: Type str doesn’t support the buffer API – Solved If you get this error Type str doesn’t support the buffer API suggests that whatever you’re trying to ouput needs to …
Read MoreRaspberry pi no Ethernet connection – solved Hey there folks – I spent about an hour to figure out how to connect my raspberry pie to the internet using an …
Read MoreLinux bash script to read parameters – Solved A simple way to create a bash script which will allow you read in the parameters entered in the terminal and handle …
Read MorePerforming OCR for Android in Xamarin using Computer Vision API Step 1. Obtain an API Key by going to the following page and registering https://www.microsoft.com/cognitive-services/en-us/computer-vision-api for Starters, the free edition …
Read MoreAdd a user to authorized_keys Hey there folks, I ran into a task where I needed to add a user to one the machiens so she could SSH into the …
Read MoreThe following app was published not too long ago which allows you to snap a picture of a math problem, and receive a detailed explanation with a solution by real …
Read MoreSend email with attachment in Xamarin Here’s the solution to send an email using the MailKit library, and ensure the email gets sent in the DEBUG and RELEASE modes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
public async Task SendMail() { var message = new MimeMessage(); message.From.Add(new MailboxAddress("Pablo", "pablo@gmail.com")); message.To.Add(new MailboxAddress("Julio", "julio@hotmail.com")); message.Subject = "We keep spending most of our lives living in the gangsta's paradise"; // create our message text, just like before (except don't set it as the message.Body) var body = new TextPart("plain") { Text = "Hi there, this is a body of the message." }; MemoryStream myImageStream = convertBMPImageToStream(bmpImage); var attachment = new MimePart("image", "jpg") { ContentObject = new ContentObject(myImageStream, ContentEncoding.Default), ContentDisposition = new ContentDisposition(ContentDisposition.Attachment), ContentTransferEncoding = ContentEncoding.Base64, FileName = "attachedImage.jpg", }; // now create the multipart/mixed container to hold the message text and the // image attachment var multipart = new Multipart("mixed"); multipart.Add(body); multipart.Add(attachment); message.Body = multipart; using(var client = new SmtpClient()) { client.Connect("smtp.gmail.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("gmailUsername", "gmailpassword"); try { await client.SendAsync(message); } catch (SmtpCommandException ex) { Console.WriteLine("Error sending message: {0}", ex.Message); Console.WriteLine("\tStatusCode: {0}", ex.StatusCode); switch (ex.ErrorCode) { case SmtpErrorCode.RecipientNotAccepted: Console.WriteLine("\tRecipient not accepted: {0}", ex.Mailbox); break; case SmtpErrorCode.SenderNotAccepted: Console.WriteLine("\tSender not accepted: {0}", ex.Mailbox); break; case SmtpErrorCode.MessageNotAccepted: Console.WriteLine("\tMessage not accepted."); break; } } catch (SmtpProtocolException ex) Console.WriteLine("Protocol error while sending message: {0}", ex.Message); client.Disconnect(true); } } |
…
Read More