Alfred Vail demonstrates a telegraph system using dots and dashes (this is the forerunner of Morse code).

Telegraphy is the long-distance transmission of messages where the sender uses symbolic codes, known to the recipient, rather than a physical exchange of an object bearing the message. Thus flag semaphore is a method of telegraphy, whereas pigeon post is not. Ancient signalling systems, although sometimes quite extensive and sophisticated as in China, were generally not capable of transmitting arbitrary text messages. Possible messages were fixed and predetermined and such systems are thus not true telegraphs.

The earliest true telegraph put into widespread use was the optical telegraph of Claude Chappe, invented in the late 18th century. The system was used extensively in France, and European nations occupied by France, during the Napoleonic era. The electric telegraph started to replace the optical telegraph in the mid-19th century. It was first taken up in Britain in the form of the Cooke and Wheatstone telegraph, initially used mostly as an aid to railway signalling. This was quickly followed by a different system developed in the United States by Samuel Morse. The electric telegraph was slower to develop in France due to the established optical telegraph system, but an electrical telegraph was put into use with a code compatible with the Chappe optical telegraph. The Morse system was adopted as the international standard in 1865, using a modified Morse code developed in Germany in 1848.The heliograph is a telegraph system using reflected sunlight for signalling. It was mainly used in areas where the electrical telegraph had not been established and generally used the same code. The most extensive heliograph network established was in Arizona and New Mexico during the Apache Wars. The heliograph was standard military equipment as late as World War II. Wireless telegraphy developed in the early 20th century became important for maritime use, and was a competitor to electrical telegraphy using submarine telegraph cables in international communications.

Telegrams became a popular means of sending messages once telegraph prices had fallen sufficiently. Traffic became high enough to spur the development of automated systemsteleprinters and punched tape transmission. These systems led to new telegraph codes, starting with the Baudot code. However, telegrams were never able to compete with the letter post on price, and competition from the telephone, which removed their speed advantage, drove the telegraph into decline from 1920 onwards. The few remaining telegraph applications were largely taken over by alternatives on the internet towards the end of the 20th century.

Alfred Lewis Vail (September 25, 1807 – January 18, 1859) was an American machinist and inventor. Along with Samuel Morse, Vail was central in developing and commercializing American telegraphy between 1837 and 1844.Vail and Morse were the first two telegraph operators on Morse's first experimental line between Washington, D.C., and Baltimore, and Vail took charge of building and managing several early telegraph lines between 1845 and 1848. He was also responsible for several technical innovations of Morse's system, particularly the sending key and improved recording registers and relay magnets. Vail left the telegraph industry in 1848 because he believed that the managers of Morse's lines did not fully value his contributions.

His last assignment, superintendent of the Washington and New Orleans Telegraph Company, paid him only $900 a year, leading Vail to write to Morse,

"I have made up my mind to leave the Telegraph to take care of itself, since it cannot take care of me. I shall, in a few months, leave Washington for New Jersey, ... and bid adieu to the subject of the Telegraph for some more profitable business."