Click here to Skip to main content
15,903,175 members
Articles / Mobile Apps

How to Send an SMS Message from a Desktop Application

Rate me:
Please Sign up or sign in to vote.
4.94/5 (89 votes)
26 Mar 2020CPOL2 min read 371.5K   18.2K   254   114
How to add the capability of sending text (SMS) messages from a desktop application
The article focuses on an implementation using MFC / C++ to explain how to add capability of sending SMS messages from a desktop application.

Sending WhatsApp Messages from a Win32 C++ Program - Part 1 - 56.7 KB


The article focuses on an implementation using MFC / C++. While looking for a reliable and cheap solution for sending SMS messages programmatically, I came across a company named CardBoardFish which covers 150 countries and provides an easy to use, yet powerful SDK for interfacing from any web site, mobile phone, or desktop application, covering most platforms and development environments. Unfortunately, among the code samples in their web site, there aren't any C++ samples, so I decided to develop my own C++ implementation.

Sending SMS Messages Programmatically

Most applications and web sites used to send SMS messages as part of their scope or among other functionalities (i.e., sending alerts, etc.) use one of the following methods:

  • HTTP Web Service -  requires using HTTP "GET" method to send a given Web Service a command, using an API, which contains the credentials, parameters, and the text for this message.
  • Email to SMS  - uses the SMTP protocol to allow sending an email in a unique format, which encodes all required parameters (credentials, sender, receiver, etc.) as part of an email.

This article focuses on the first method, using a Web Service.


The following table lists all parameters that can (or should) be sent to the Web Service:

Image 1

Using the Code

The code in this article was developed in MFC / C++ using Visual Studio 2010 Ultimate. I also used Cheng Shi's HTTPClient (thanks Cheng!).

In order to use the code for your own application, it is advised to read the specifications for the SDK named HTTPSMS. Secondly, you need to open an account and obtain your user name and password, which can be hardcoded in the source code, or entered during runtime.

The SendSMS Application  

SendSMS Screen

The main functionality of our application is obviously sending an SMS, which is done in the following function:

// SendSms  - by Michael Haephrati
BOOL SendSms(CString From, CString CountryCode, CString To,CString Message,CString *Status)
    // From - the ID or number you are sending from. 
    // This is what will appear at the recipient's cellphone. 
    // CountyCode - the code of the country you are sending the SMS to 
    // (for example: 44 is for the UK
    // To - is the number you are texting to, 
    // which should not contain any leading zeros, spaces, commas, etc.
    // Message - is the message you are sending, which can be any multi lingual text
    // The status returned would be either a confirmation number along with the text "OK", 
    // which means that the message
    // was delivered, or an error code. 
    BOOL result=FALSE;
    wstring user=L"PLACE_YOUR_USERNAME_HERE",pass=L"PLACE_YOUR_PASSWORD_HERE",request=L"";
    request=L"http:   //";
    request+=user;    // user name
    request+=pass;    // password
    request+=(wstring)(CountryCode+To); // country code
    request+=(wstring)From;             // From (sender ID)
    CString EncodedMessage;             // Message
    CString ccc;
                   ( L" here you can place your marketing piech, website, etc.");
    request+=(wstring)EncodedMessage;   // Message to send

    // Indicating that this message is encoded as opposed to plain text 

Now we handle the HTTP "GET" request:

    WinHttpClient client(request); 
    // Get the response

    wstring httpResponseHeader = client.GetResponseHeader();
    wstring httpResponseContent = client.GetResponseContent();
    return result; 

Other Services

I have tested the services of CardBoardFish, which I used for the attached source code. They provide their own code samples here, but these don't include C++, which I why I wrote the test application attached to this article.

I recently tested another service they provide which is verifying mobile numbers before sending the text messages. I didn't include this functionality because I found it to be too slow, and also it doesn't cover some countries, among them... USA.  

I found another alternative service provider,, so there are several options to choose from.  

Further Reading 

Please refer to another article of mine, this time explaining how to do the same using iOS (iPhone / iPad). 


  • 1st July, 2013: Initial version


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

Written By
CEO Secured Globe, Inc.
United States United States
Michael Haephrati is a music composer, an inventor and an expert specializes in software development and information security, who has built a unique perspective which combines technology and the end user experience. He is the author of a the book Learning C++ , which teaches C++ 20, and was published in August 2022.

He is the CEO of Secured Globe, Inc., and also active at Stack Overflow.

Read our Corporate blog or read my Personal blog.

Comments and Discussions

SuggestionNo URL parameter escaping Pin
Chad3F2-Apr-20 10:30
Chad3F2-Apr-20 10:30 
QuestionEnviar SMS atraves de umTXT Pin
Member 1462781119-Oct-19 7:28
Member 1462781119-Oct-19 7:28 
AnswerRe: Enviar SMS atraves de umTXT Pin
Michael Haephrati26-Mar-20 13:36
professionalMichael Haephrati26-Mar-20 13:36 
QuestionReset all fields after send? Pin
Member 136555921-Feb-18 23:03
Member 136555921-Feb-18 23:03 
AnswerRe: Reset all fields after send? Pin
Michael Haephrati26-Mar-20 13:36
professionalMichael Haephrati26-Mar-20 13:36 
Answerexe file Pin
Member 113470877-Apr-17 1:35
Member 113470877-Apr-17 1:35 
GeneralCorrupted download file? Pin
Avelino Ferreira1-Dec-16 10:36
professionalAvelino Ferreira1-Dec-16 10:36 
GeneralRe: Corrupted download file? Pin
Avelino Ferreira1-Dec-16 10:48
professionalAvelino Ferreira1-Dec-16 10:48 
GeneralRe: Corrupted download file? Pin
Michael Haephrati2-Dec-16 6:09
professionalMichael Haephrati2-Dec-16 6:09 
SuggestionTitle should be precise? Pin
Eytukan5-Apr-16 5:25
Eytukan5-Apr-16 5:25 
GeneralRe: Title should be precise? Pin
Michael Haephrati5-Apr-16 5:29
professionalMichael Haephrati5-Apr-16 5:29 
GeneralRe: Title should be precise? Pin
Eytukan5-Apr-16 6:27
Eytukan5-Apr-16 6:27 
GeneralRe: Title should be precise? Pin
Michael Haephrati5-Apr-16 8:05
professionalMichael Haephrati5-Apr-16 8:05 
GeneralRe: Title should be precise? Pin
Eytukan5-Apr-16 19:07
Eytukan5-Apr-16 19:07 
QuestionSend SMS from PC Pin
Daniel Rozsar5-Oct-13 9:15
professionalDaniel Rozsar5-Oct-13 9:15 
AnswerRe: Send SMS from PC Pin
muazam124-Dec-14 4:29
muazam124-Dec-14 4:29 
GeneralRe: Send SMS from PC Pin
Michael Haephrati4-Dec-14 7:20
professionalMichael Haephrati4-Dec-14 7:20 
QuestionVS 2008 and Character set Pin
Sasa Kajic15-Jul-13 0:09
Sasa Kajic15-Jul-13 0:09 
NewsUpdate Pin
Michael Haephrati1-Jul-13 6:06
professionalMichael Haephrati1-Jul-13 6:06 
QuestionConvertHex Pin
Graeme_30-Jun-13 16:53
Graeme_30-Jun-13 16:53 
AnswerRe: ConvertHex Pin
Michael Haephrati1-Jul-13 4:42
professionalMichael Haephrati1-Jul-13 4:42 
GeneralRe: ConvertHex Pin
Graeme_6-Jul-13 4:18
Graeme_6-Jul-13 4:18 
AnswerRe: ConvertHex Pin
Dusan Paulovic29-Sep-13 9:30
Dusan Paulovic29-Sep-13 9:30 
GeneralRe: ConvertHex Pin
Michael Haephrati29-Sep-13 9:51
professionalMichael Haephrati29-Sep-13 9:51 
GeneralMy vote of 5 Pin
alonbarak14-Jun-13 11:07
alonbarak14-Jun-13 11:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.