Updated for bounty. What I am after is a simple way to send e-mail when I click a button on one of my LightSwitch Screens. I need to be able to access data from any screen (to collect and process it) so it can be sent as an e-mail. How can this be done without breaking my back over it, or using any third party components or services? Third party stuff isn’t an option in this case.
I have followed every tutorial I could find, and it just doesn’t work. I cannot send an email to someone from a LightSwitch application, no matter how I do it. I can send email from WinForms, WPF, Websites – so I know it’s not my code that’s the problem.
I have followed this tutorial to a “T”, and (http://blogs.msdn.com/b/bethmassi/archive/2011/01/27/how-to-send-html-email-from-a-lightswitch-application.aspx) it still won’t work. First, here are my current issues:
- In this tutorial, it tells you to add your Class.cs file to the UserCode folder in the Server folder – I did that.
- It also tells you to Add a reference to System.Net.Mail (obviously) – I tried that. System.Net.Mail is not available to be added. I can’t find it anywhere!
- Every other tutorial is the same – so there’s nothing else that I can try, that I know of.
As you can see below, I try adding System.Net.Mail as a reference, but it’s not there in the list. I’ve also tried adding the using System.Net.Mail to the top of the files, but like I said; it’s not available/does not exist/whatever.

Anyone know how to send email from a LightSwitch application?
Note, this is not a service, or website type project, just a simple Desktop Lightswitch app.
I have an invoice management app that I’m making, and the only part left is to auto-send a payment due reminder email if the payment is way overdue, based on the DateDue value in the table.
I’ve seen other comments on MSDN forums by people who said that System.Net.Mail is not available in Silverlight, and that’s why it’s not there in LightSwitch. I don’t know if that’s true or not, but it certainly is looking that way. Why couldn’t they have just made System.Net.Mail available for LightSwitch apps without making us jump through hoops just to get it working?
Even though I said I know my code is fine, I’ll post it anyway.
C#: (Note that in my CLASS file System.Net.Mail IS available HOWEVER, I am not able to access any part of this code in this file from anywhere else or any other file in my entire project!)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
namespace LightSwitchApplication
{
public class JTS
{
public class Mail
{
public string recipient { get; set; }
public string subject { get; set; }
public string message { get; set; }
public void Send()
{
using (MailMessage mailmessage = new MailMessage())
{
mailmessage.From = new MailAddress("@.com");
mailmessage.To.Add(recipient);
mailmessage.Subject = subject;
mailmessage.Body = message;
mailmessage.Priority = MailPriority.High;
using (SmtpClient client = new SmtpClient())
{
client.Credentials = new System.Net.NetworkCredential("@.com", "_SVN");
client.EnableSsl = false;
client.Host = "m..com";
client.Port = 25;
client.Send(mailmessage);
}
}
}
}
}
}
System.Net.Mailis a namespace, not an assembly. Try adding a reference toSystem.Netto see if that helps.That tutorial you mentioned references
this one, where it is
System.Netthey are adding the reference to.