Today we’ll see one simple functionality of sending email from Silverlight application. I know many of you think that it is a very simple stuff.
Let’s do it using your Outlook application. To achive this we need to use a class called AutomationFactory which is available in System.Runtime.InteropServices.Automation.AutomationFactory.
Here is the code, which is very straight forward. But remember you must have to run the application out of browser to make this work!!
You need to add
using System.Runtime.InteropServices.Automation; var outlook = AutomationFactory.CreateObject("Outlook.Application"); var olMail = outlook.CreateItem(0); olMail.To = txtTOEmailAddress.Text; olMail.Cc = txtCCEmailAddress.Text; olMail.Attachments.Add(@"C:\mypic.jpeg"); olMail.Subject = txtsubject.Text; olMail.HTMLBody = txtmessage.Text; olMail.Display(); olMail.Save(); //You can send a mail by using Send() method. olMail.Send();
I hope this will help someone.