A telegraph system using dots and dashes was demonstrated by Alfred Vail on 6th January 1838. This was the forerunner of the Morse code. Vail, a machinist and inventor, developed the Morse code along with Samuel Morse.
The first telegraph line was inaugurated by Samuel Morse on 24th May 1844 when he sent a message – What hath God wrought – from Old Supreme Court Chamber in the US Capitol to Vail in Baltimore, Maryland.