Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am new to silverlight.

I am not getting the correct code to implement this concept.

I have four textboxes and one button by name submit in my xaml page,one is from textbox,2nd is to textbox,3rd is subject textbox and last one is body textbox.

When user clicks on submit button mail should go to the particular email address were we have assigned it in the to textbox from the particular address were we have assigned it in the from textbox.

I want to know different methods to implement this concept.

Thanks,
swapna.
Posted
Updated 20-Jan-11 1:43am
v2

If you google "C# send mail", you'll get 708 thousand results back. Here's a code snippet from one of them.

C#
try
{
    MailMessage mail = new MailMessage();
    SmtpClient SmtpServer = new SmtpClient("smtp.yourdomain.com");

    mail.From = new MailAddress("your_email_address@yourdomain.com");
    mail.To.Add("to_address@domain.com");
    mail.Subject = "Test Mail";
    mail.Body = "This is for testing SMTP mail from GMAIL";

    SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
    SmtpServer.Port = 587; // only do this if you need to
    SmtpServer.EnableSsl = true; // only do this if you need to

    SmtpServer.Send(mail);
}
catch (Exception ex)
{
    // handle exception
}
 
Share this answer
 
v3
Comments
Nish Nishant 20-Jan-11 9:51am    
SmtpClient is apparently not available in Silverlight.
Abhinav S 20-Jan-11 11:04am    
I guess this code would on the WCF side.
Nish Nishant 20-Jan-11 11:11am    
Not all SL apps use WCF :-)
I don't think SmtpClient is supported in Silverlight. You can use a webservice to do the actual emailing, and your Silverlight app can then send email through the webservice by sending it the required info.

See this forum thread on the same topic:

http://forums.silverlight.net/forums/t/12762.aspx[^]
 
Share this answer
 
v2
Comments
#realJSOP 20-Jan-11 11:05am    
Another arbitrary omission in Silverlight...
Nish Nishant 20-Jan-11 11:11am    
Agree.
This[^] surely should help you out.
 
Share this answer
 
Comments
msnisah 25-Jan-12 7:50am    
hiiiiiiiiiii
msnisah 25-Jan-12 7:53am    
I want to start Silverlight anybody can help me..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900