More code released

24 03 2011

I had a hour of free time, going through some code i have used in the past, and i’ve posted them in the code section (see menu above).

Also, you can never look past code you do not understand so try to understand what is written when you use it.

I’ve got plenty more but this is what i could find in some of my recent coding folders.

Yippy, more code! (i was testing the robustness of someone' elses 3D augmented skeleton code, and it crashed when i jumped. That is because of my lightningfastness ofcourse.





Send email with Gmail in C# (C sharp)

15 03 2011

This code is old, new code with example is on the new website.

Don’t use the GmailHelper library. It seems great, but i couldnt get it working on 2010 express since it had all kinds of old dependencies.
Sending email with c# is super easy, but it took me an hour to work it out, so as a note to myself and for your possibly convenience, we can use the following:

  1. declare
    using System.Net.Mail;

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("ACCOUNT@gmail.com", "PASSWORD");
mail.To.Add("RECEIVER@RECEIVER.com");
mail.Subject = "subj";
mail.From = new System.Net.Mail.MailAddress("ACCOUNT@gmail.com");
mail.IsBodyHtml = true;
mail.Body = "message";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);