Ibraheem Osama Mohamed (ابراهيم اسامه محمد)

Welcome to my blog :)

SNTP and Silverlight

leave a comment »

You can’t use SNTP in Silverlight so you must use a web service that makes the SNTP (Gmail SNTP)
This is the steps for how to make a SNTP using Siverlight

Steps
1)Open New Silverlight Application.
2)Add a New WCF Application in the Silverlight’s ASP.NET Project so you can consume the web service.
3)Add a button and a textbox textbox that you’ll write the email you want to send him the message “Forget password”.
4)In the Button_Click Event Consume the web service and give it the textBox text
5)Open the IService and add a
[OperationContract]
string SendEmail(string b);
6)Open the service.svc.cs and add

public string SendEmail(string email)
          { 
var fromAddress = new MailAddress("......@gmail.com""From Name");                             
var toAddress = new MailAddress(email, "To Name");                              
const string fromPassword = "012345678997531";                              
const string subject = "Your Password";                              
string body = "This is your password:" + password + "\n for more information contact us omelkora.its@gmail.com"; 
var smtp = new SmtpClient                              
{                                  
Host = "smtp.gmail.com",                                  
Port = 587,                                  
EnableSsl = true,                                  
DeliveryMethod = SmtpDeliveryMethod.Network,                                  
UseDefaultCredentials = false,                                  
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)                              
};                              
using (var message = new MailMessage(fromAddress, toAddress)                              
{                                  
Subject = subject, Body = body                              
})                              
{                                  
smtp.Send(message);                              
}
}

 Try The Code and everything will be OK 🙂

Ibraheem Osama Mohamed
Twitter : @IbraheemOsamaMo

Advertisements

Written by Ibraheem Osama Mohamed

May 5, 2012 at 1:27 pm

Posted in C#, gmail, Silverlight, SNTP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: