You can use the Wizard "Configure Database Mail" in the Microsoft SQL Server Management Studio (Node: Management -> Node: Database Mail -> context menu).
See screenshot https://techscreen.tuwien.ac.at/sites/default/files/databasemail.png
USE msdb;
GO
EXECUTE dbo.sysmail_start_sp;
GO
To verify that the database mail profile is configured properly you can select „Send Test E-Mail“ from the context menu above.
USE [msdb];
GO
CREATE USER [userxy] FOR LOGIN [userxy];
GO
USE [msdb];
GO
EXEC sp_addrolemember N'DatabaseMailUserRole', N'userxy'
GO
Example code:declare @msg varchar(500)
set @msg = 'test email vom server, getriggert über sql query'
exec msdb.dbo.sp_send_dbmail @recipients=N'c.ploessnig@irgendwas.at', @body=@msg, @subject='Test', @profile_name = 'anexia'
For further specification and arguments see https://msdn.microsoft.com/de-de/library/ms190307(v=sql.120).aspx