Click here to Skip to main content
15,900,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone.. i am trying to send sms from my windows mobile 6.5 application.
but i am getting exception "SmsException".
"error sending Sms message"

following code segment i am using for sending sms
OutlookSession session = new OutlookSession()
Recipient recipient = new Recipient ("someName","9876543210");

SmsMessage message = new SmsMessage ();
message.To.Add(recipient);
message.Body="hi";
message.RequestDeliveryReport = true;
message.Send();
Posted
Updated 7-Dec-10 18:21pm
v3
Comments
Dylan Morley 7-Dec-10 9:15am    
Edit your question and post in the full SmsException details, e.g the full Exception message
Abhinav S 8-Dec-10 0:25am    
This exception is probably occuring somewhere in the SmsMessage() class - check there.
Ashutosh kumar Tripathi 8-Dec-10 0:36am    
Thanx for your comment . I check inner exception .. It says that "Could not evaluate expression" .. and i have no clue about which expression its talking about. I am totally new for this technology. Can you help me?
senguptaamlan 8-Dec-10 2:21am    
Are you running the application in simulator...if yes then try to run it an an Windows Mobile 6.5 device....
Ashutosh kumar Tripathi 8-Dec-10 4:56am    
@sen .. thanx :) its working on device

1 solution

To start, do something like this:

C#
public void DoTheJob() {
    try {
        //call your code: create SMS Message, ..., Send()...
    } catch (System.Exception e) {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        ReportException(e, sb);
        //output sb.ToString() to some file
    }
}
public static void ReportException(
       System.Exception e,
       System.Text.StringBuilder destination) {
    destination.Append(string.Format("Exception {0}:", e.GetType()));
    destination.Append(string.Format("'{0}'", e.Message));
    foreach (var data in e.Data)
        destination.Append(data.ToString());
    destination.Append("Inner Exception");
    ReportException(e.InnerException, destination);
}


This will give you really comprehensive information on exception. Output sb.ToString() to some file and publish its contents here (if you did not figure our the problem yet).
 
Share this answer
 
v5

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