Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public ShortMessageCollection ReadSMS(SerialPort port)
       {
           // Set up the phone and read the messages
           ShortMessageCollection messages = null;
           try
           {
               #region Execute Command
               // Check connection
               ExecCommand(port, "AT", 300, "No phone connected");
               // Use message format "Text mode"
               ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.");
               // Use character set "PCCP437"
               ExecCommand(port, "AT+CSCS=\"PCCP437\"", 300,
               "Failed to set character set.");
               // Select SIM storage
               ExecCommand(port, "AT+CPMS=\"SM\"", 300,
               "Failed to select message storage.");
               // Read the messages
               string input = ExecCommand(port, "AT+CMGL=\"ALL\"", 5000,
                   "Failed to read the messages.");
               #endregion

               #region Parse messages
               messages = ParseMessages(input);
               #endregion
           }
           catch (Exception ex)
           {
               throw new Exception(ex.Message);
           }

           if (messages != null)
               return messages;
           else
               return null;
       }
Posted
Updated 5-Oct-11 1:13am
v2
Comments
CodingLover 5-Oct-11 7:13am    
Edit: wrap with the relevant code tags
CodingLover 5-Oct-11 7:14am    
Did you include relevant reference? The one you are using is not a standard on .Net or any other known framework to me.

The solution is in the error message:
The type or namespace name 'ShortMessageCollection' could not be found (are you missing a using directive or an assembly reference?) 
Check you have a using statement referring to the relevant namespace.
Then check that the DLL containing the namespace is in your list of project references.

Whichever is missing (could be both) add it.
 
Share this answer
 
The message is clear, you are missing a using directive or an assembly reference.

Where is the ShortMessageCollection declared? In an external assembly? another project maybe? If in the same project, be sure that you added a proper namespace via using directive.

Cheers
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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