Do you want to have various functions in the APP you developed? In this article, I will briefly explain to you how to write a newsletter function.
Preface
Do you want to have various functions in the APP you developed? In this article, I will briefly explain to you how to write a newsletter function.
Description
// Create an initiator object for sending SMS
Microsoft.Phone.Tasks.SmsComposeTask object = new Microsoft.Phone.Tasks.SmsComposeTask();
The above object provides the following members (attributes or methods) for Specify mailing information:
To: Specify the recipient’s phone number
Body: SMS content
Show(): Call the system’s built-in SMS sending program
p>
Method
Step1: Build a project
Step2: Screen design
Arrange the following screen in the Grid, and its important controls are as follows:
- 1. TextBox control, Name attribute -> txtPhone
- 2. TextBox control, Name attribute -> txtSMS
- 3. Button control, Name attribute -> btnSend, Content attribute -> Send
The screen configuration is as follows:
The generated XAML program is as follows:
< p> Step3: Event handling function
// Constructor
public MainPage()
{
InitializeComponent();
// Program example to localize ApplicationBar
//BuildLocalizedApplicationBar();
btnSend.Click += btnSend_Click;
}
void btnSend_Click(object sender, RoutedEventArgs e)
{
// Create a launcher object for sending SMS
Microsoft.Phone.Tasks.SmsComposeTask sms = new Microsoft.Phone.Tasks.SmsComposeTask();
// Specify the recipient's phone number
sms.To = txtPhone.Text;
// Specify the content of the newsletter
sms.Body = txtSMS.Text;
// Start sending SMS
sms.Show();
}
Results
Specify recipients and text message content.
p>
SMS sent successfully
< /p>
Concluding remarks
The writing method of the newsletter function is very simple, here is for your reference ^^
Sample download
SmsPhoneApp.zip
Original text: Large column [Windows Phone] How to write SMS function