Josh-CO Dev

Solving the worlds problems one line of code at a time.

Leave a comment

Sending Emails from Silverlight

One of the requirements of my application I am writing is to send emails upon the creation of a new comment. This turned out to be quite simple. I am using RIA services and a Domain Service. In my domain service, I simply added the following code. I have noticed that this does not seem to work through GoDaddy, but it does test fine from my machine.

public string SendEmail(string to, string body, string subject)
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(to));
msg.From = new MailAddress(“”);
msg.Body = body;
msg.Subject = subject;
SmtpClient smtp = new SmtpClient();
smtp.Host = “”;
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential(“gmailaccount”, “gmailpassword”);
smtp.Port = 587;
return “Success”;
catch (Exception ex)
return ex.ToString();



Leave a comment

Silverlight Image Source Binding

I figured out something that just happened to be a life saver yesterday. I have been working on a more social tool for my workout tracking program. One thing I wanted was a comment system that would show the user’s profile picture. I spend forever trying to think of a way to loop through the list box. What I ended up with was much more simple:

 Here is the XAML:

<StackPanel Orientation=”Horizontal”>

<Image Grid.Row=”1″ Height=”64″ Source=”{Binding ImagePath}” HorizontalAlignment=”Left” Margin=”5,5,0,0″ x:Name=”imgProfileImage” Stretch=”Fill” VerticalAlignment=”Top” Width=”64″ />


The backend code simply sets the ImagePath binding to a path that is stored in the database.


Leave a comment

Silverlight WCF RIA Issues – Implement Domain Service

As i’ve mentioned in previous posts, I have been having some issues with WCF services in Silverlight. On my local computer, my application would compile and run just fine. When I would move the web service out to my host, GoDaddy, I would always get back errors that did not make any sense. I scoured the internet and found nothing of use. I have a clientaccesspolicy.xml, crossdomainpolicy.xml and did everything else the web told me. I then stumbled into some articles about using the entity framework with RIA calls, I am using LinqToSQL. These articles uses a domain services file to interface with the web service. I implemented this and everything began working. The weird thing is, so far it seems that I only need to expose the table itself through the domain service. I can still make all my web service calls, inserts, etc by calling my web service directly. Most frustrating problem ever!