Saturday 1 September 2012

Create Windows 8 keyboard shortcuts for you Apps

Don't drag your mouse around metro like an idiot, set your shortcut keys. Here's how -


1. Find your app in the Start Menu folder location:
      C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

2. Right-Click your apps shortcut, click Properties, select the Shortcut field and enter a key combination.
      Like <ctrl> <alt> <letter>


What to do if you have a shortcut for your app in Metro but not in the Start Menu folder ? 


1. Un-Pin the icon from Metro










2. Find the apps executable (usually in C:\Programs Files...), and pin it to Start again.



Friday 3 August 2012

Using C# to send authenticated email through Exchange 2010

problem :

Our Exchange 2010 environment requires that all users (with some exceptions to servers) authenticate before sending email, and that communication takes place over SSL using certificates.

I've found it somewhat difficult to achieve this, due to the following errors -

1. The Server response was: 5.7.1 Client does not have permissions to send as this sender
2. The remote certificate is invalid according to the validation procedure

solution :

1. The only way I can send from my mailbox is by giving another account (like a service account) 'Send As' permissions on it and specifying those credentials. My own credentials produce the above error.

2. When specifying the Host or Server (which is the Client Access Server in Exchange speak), you need to either use the host name that is included on its certificate, or include this line of code to ignore certificate errors -

ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

Thanks. Here is my method -
Jim

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;

namespace Send_Email_BVCAS2010
{
    class Program
    {
        static void Main(string[] args)
        {
            SmtpClient smtpClient = new SmtpClient();
            NetworkCredential basicCredential = new NetworkCredential("domain\\user", "password");   // User with 'sendAs' permissions on the mailbox. Cannot use your own creds
            MailMessage message = new MailMessage();
            MailAddress fromAddress = new MailAddress("sender@domain.com.au");   // From this mailbox..

            smtpClient.Host = "CAS_Server_Name";
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = basicCredential;
            smtpClient.EnableSsl = true;

            message.From = fromAddress;
                          message.Subject = "test in c#";
            //Set IsBodyHtml to true means you can send HTML email.
            message.IsBodyHtml = true;
            message.Body = "<h1>Message BODY</h1>";
            message.To.Add("recipient@domain.com.au");

            try

            {
                ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
                smtpClient.Send(message);

            }
            catch (Exception ex)
            {
                //Error, could not send the message
                Console.WriteLine(ex.Message);
                Console.WriteLine("Finished");
                Console.ReadLine();
            }
        }
    }
}




Wednesday 14 December 2011

Using Alpine - with a Password File

Alpine is a text based email client.. (and news reader). I'm using it for (gmail) email at the moment. Quite nerd-ish and cool.

To make things easier on yourself, configure Alpine to save your email password in a file like so:

1. Check if your version of alpine includes password file support: alpine -h | grep passfile
2. If you get something like - -passfile <fully_qualified_filename>, it does
3. Create a new file, run touch newfile then launch alpine thus-ly - alpine -passfile /home/jimc/.pine-passfile

Friday 9 December 2011

F16 and Grub2 Text Boot

Now that I am using Fedora 16, I want to be able to customize Grub2..

For starters, here's how to get a text boot

1. Edit /etc/default/grub) =


2. Remove "quiet" and "rhgb"
3. Run # grub2-mkconfig -o /boot/grub2/grub.cfg

Friday 27 May 2011