Kieran Kyle sent emails to the Tory party leader in which he made racist references, a court hears.