2012-11-27 6 views

Antwort

11

Bitte geben Sie die Anleitung in den folgenden Link

http://www.windowsphonegeek.com/tips/How-to-compose-and-send-SMS-from-Windows-Phone-apps

Dies sollte helfen sehen. Bitte beachten Sie, um endlich eine SMS-Benutzerinteraktion zu senden ist ein Muss, das können Sie nicht automatisieren. Der Benutzer muss

Taste SMS senden

vollständige Code

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Navigation; 
using Microsoft.Phone.Controls; 
using Microsoft.Phone.Shell; 
using PhoneApp1.Resources; 
using Microsoft.Phone.Tasks; 

namespace PhoneApp1 
{ 
    public partial class MainPage : PhoneApplicationPage 
    { 
     // Constructor 
     public MainPage() 
     { 
      InitializeComponent(); 

      // Sample code to localize the ApplicationBar 
      //BuildLocalizedApplicationBar(); 
     } 

     private void Button_Click_1(object sender, RoutedEventArgs e) 
     { 
      SmsComposeTask smsComposeTask = new SmsComposeTask(); 

      smsComposeTask.To = _Number.Text; 
      smsComposeTask.Body = _Message.Text; 
      smsComposeTask.Show(); 
     } 

     // Sample code for building a localized ApplicationBar 
     //private void BuildLocalizedApplicationBar() 
     //{ 
     // // Set the page's ApplicationBar to a new instance of ApplicationBar. 
     // ApplicationBar = new ApplicationBar(); 

     // // Create a new button and set the text value to the localized string from AppResources. 
     // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); 
     // appBarButton.Text = AppResources.AppBarButtonText; 
     // ApplicationBar.Buttons.Add(appBarButton); 

     // // Create a new menu item with the localized string from AppResources. 
     // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); 
     // ApplicationBar.MenuItems.Add(appBarMenuItem); 
     //} 
    } 
} 
+0

freiere Verwendung zu sein, was passiert, wenn Sie versuchen, und senden mehr als 140 Zeichen im Körper? – Beanwah

+0

@Beanwah Habe das nie versucht, aber da es direkt von der standardmäßig bereitgestellten Aufgabe gehandhabt wird, sollte es kein Problem geben – Harshit

0

diese Funktion

//---sends an SMS message to another device--- 
private void sendSMS(String phoneNumber, String message) 
{ 
    SmsComposeTask smsComposeTask = new SmsComposeTask(); 
    smsComposeTask.To = phoneNumber; 
    smsComposeTask.Body = message; 
    smsComposeTask.Show(); 
}