HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to create and send mail in SQL Server 2008?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
2008createserversqlmailhowandsend

Problem

I want to send E-mail from SQL Server 2008. What are the basic steps for that? Can you explain me if someone used this facility.

Any help will appreciated.

this link will helpful as commented by marc_s (also I have accepted an answer below)
http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/

Solution


  • In SSMS object Explorer, click Management



  • Right-click Database Mail



  • Click Configure Database Mail



4.Select Set up Database Mail by performing the following tasks

5.Enter a profile name and click Add

6.Enter the settings for your email account. I could not set the account for my company's email account - it just didn't work. But I had no trouble with setting the Gmail account I use and these are the parameters that you should use for the Server name and Port number

It is not possible to send attachments from SSMS, you have to use T-SQL for that:

EXEC msdb.dbo.sp_send_dbmail
@profile_name='carol Gmail',
@recipients='john@john.com',
@subject='Test email',
@body='Attachment test',
@file_attachments='D:\123\pic.jpg'

Code Snippets

EXEC msdb.dbo.sp_send_dbmail
@profile_name='carol Gmail',
@recipients='john@john.com',
@subject='Test email',
@body='Attachment test',
@file_attachments='D:\123\pic.jpg'

Context

StackExchange Database Administrators Q#10190, answer score: 7

Revisions (0)

No revisions yet.