vcbgvhgf
vcbgvhgf

Reputation: 3

How to send e-mail from SQL Server?

I have configured database mail – send email ...create one account also... I used below query

EXEC msdb.dbo.sysmail_add_profile_sp
@profile_name = 'SQL 2008 Profile',
@description = 'Used for general-purpose emailing.'

The second script creates the new SMTP account:

EXEC msdb.dbo.sysmail_add_account_sp
@account_name = 'MailAcct1',
@description = 'SMTP Account.',
@email_address = '[email protected]',
@display_name = 'Mail Account',
@mailserver_name = 'smtp.gmail.com' ;

The third script associates this new account with the new profile:

EXEC msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'SQL 2008 Profile',
@account_name = 'MailAcct1',
@sequence_number =1;

exec msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'SQL 2008 Profile',
@principal_name = 'public',
@is_default = 0 ;


exec msdb.dbo.sysmail_configure_sp 'AccountRetryDelay', 1200

After all I go to sent test mail... after write to address getting error like

your test email has has been queued for processing.Depending on the network speed and the backlog of the SMTP server.it may take several minutes before the email is delivered to the receipt

please help me out...

One more sent test mail they asking one to address in there actually what I need to written email or servername

Upvotes: 0

Views: 12868

Answers (2)

John Emeres
John Emeres

Reputation: 473

Try setting up database email through SSMS. There are more options in the GUI than you are using in your stored procedures.

You might need to set port number or some other small option that is in fact required.

Also, when sending through Gmail you need to enable external SMTP before you can start using it.

Upvotes: 0

hd1
hd1

Reputation: 34657

You should use SQL Server's built-in mailer. After the wizard is set up, sending mail is trivial:

USE msdb
GO
EXEC sp_send_dbmail @profile_name='PinalProfile',
@recipients='[email protected]',
@subject='Hello world',
@body='Hello alien world, from ours, we come in peace.'

Upvotes: 1

Related Questions