Sample Header Ad - 728x90

sp_send_dbmail not working but send test e-mail for database mail working

0 votes
0 answers
161 views
I set up database mail on a SQL Server. When I send a test e-mail form SSMS it works. When I try to send an email using msdb.dbo.sp_send_dbmail via the query window I get: Mail (Id: xx) queued. but email not sent. log of email that sent via test e-mail form SSMS (sent successfully): Profile ID | Recipients| Copy Recipients | Blind Copy Recipients | Subject | From Address | Reply To | Body | Body Format | Importance | Sensitivity | File Attachments | Attachment Encoding | Query | Execute Query Database | Attach Query Result as File | Query Result Header | Query Result Width | Query Result Separator | Exclude Query Output | Append Query Error | Send Request Date | Send Request User | Sent Account ID | Sent Status | Sent Date | Last Mod Date | Last Mod User | |--------------|------------|------------------------|------------------|-----------------------|---------|--------------|----------|------|-------------|------------|-------------|------------------|---------------------|-------|------------------------|----------------------------|--------------------|-------------------|------------------------|----------------------|-------------------|-------------------------|-------------------|-----------------|-------------|------------------------|------------------------|----------------| 17 | myemail@gmail.com | NULL | NULL | Subject | NULL | NULL | Body | TEXT | NORMAL | NORMAL | NULL | MIME | NULL | 0 | 1 | 256 | 0 | 0 | 0 | 0 | 2024-10-10 12:10:02.467 | myuser | 11 | 1 | 2024-10-10 12:10:08.000 | 2024-10-10 12:10:08.900 | sa | log of email that sent via query (queued but not sent):
EXECUTE msdb.dbo.sp_send_dbmail
	@recipients = 'myemail@gmail.com',
	@subject = 'Subject',
	@body = 'Body',
	@profile_name = 'MyProfile'
| Profile ID | Recipients | Copy Recipients | Blind Copy Recipients | Subject | From Address | Reply To | Body | Body Format | Importance | Sensitivity | File Attachments | Attachment Encoding | Query | Execute Query Database | Attach Query Result as File | Query Result Header | Query Result Width | Query Result Separator | Exclude Query Output | Append Query Error | Send Request Date | Send Request User | Sent Account ID | Sent Status | Sent Date | Last Mod Date | Last Mod User | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 17 | myemail@gmail.com | NULL | NULL | Subject | NULL | NULL | Body | TEXT | NORMAL | NORMAL | NULL | MIME | NULL | 0 | 1 | 256 | 0 | 0 | 0 | 0 | 2024-10-10 12:01:15.897 | myuser | NULL | 0 | NULL | 2024-10-10 12:01:15.897 | sa | I checked the sysmail_faileditems, and there are no error logs related to what I sent... Why it is working via test e-mail form SSMS but not via query?
Asked by Ranel (1 rep)
Oct 15, 2024, 09:04 AM