0845 356 5758
or

C# Code Sample

Introduction

Esendex provides the SendMessageConsole application to be used to send messages from a Windows desktop. This small application differs from PC SMS as it is executable from the command line. This means that it can be called, for example, from batch files or system monitoring tools.

The source code for this application is provided to developers primarily as a means to demonstrate how to send a message using the C# programming language. It also shows the best practices developers are encouraged to follow with regards to exception handling, etc.

System Requirements and Prerequisites

  • Visual Studio.Net with Microsoft .Net Framework 1.1
  • Basic understanding of Web Services and using Application Configuration files
  • A live Esendex account with a valid username and password
  • Proxy authentication details if you have a proxy that requires them
  • An internet connection

Getting Started

  1. Download the C# Send Message Console Application zip file from the Code Samples section of our Downloads page
  2. Unzip the file to a directory of your choice
  3. Open CSharpSendMessageConsole.sln in Visual Studio.Net

Code Description

After the initial basic checks to make sure enough command line parameters have been provided, the code can be segmented into the following sections:

  1. Loads details from the configuration file
  2. Parses the recipients provided in the command line
  3. Instantiates a SendService object and assigns Esendex authentication details to the header
  4. Set up the proxy if one is required
  5. Submits the message to Esendex

Comments are provided in the code that describes these sections in more detail

Configuration File Description

Please view the Configuration File page for a description of the settings which can be applied.