One of my client complained that he is receiving an email in every 30 minutes from last 20 days. The sender ID is TACTaddress with Subject XXX formatting completed. There is no any other information in the email.
I have the Admin access to all the SQL Servers of my company. How can I trace from which server the mail is getting generated?
You could use this view to look up emails sent from your SQL Server:
select * from msdb.dbo.sysmail_sentitems
Related
Context: I keep raising this error when I try to execute an SSRS Email or File Drop subscription - and I have no idea why. The empty string '' seems to imply I need to add some specific user information but I have no idea where.
I was able to send a test email through the Database Mail wizard in the management studio. I noticed in the SQL Server sysmail_event_log record for that event the last_mod_user was NTService\MSSQLSERVER. But the failed subscription execution attempts are showing up under the sa in the last_mod_user I suspect something is at play between this discrepancy but idk how to fix it.
The error description also reads:
The mail could not be sent to the recipients because of the mail
server failure. (Sending Mail using Account 4 (2022-04-22T17:41:01).
Exception Message: Cannot send mails to mail server. (The SMTP server
requires a secure connection or the client was not authenticated. The
server response was: 5.7.57 Client not authenticated to send mail.
[BN0P110CA0026.NAMP110.PROD.OUTLOOK.COM]). )
Questions: Can someone please assist?
Add the account to the Local Admin of the Machine to fix the Operation.Mail one
I am wondering if it's possible to run a job automatically in SQL Server when an email with specific subject is received on Outlook, so that I don't need to go through all my mails everyday and run the job manually.
I have googled this topic but most of articles were about sending an email from SQL Server when the job is finished for example.
Has anyone done this before and can guide me, please? If there is a way to do this.
Thank you.
OR You can use a more current technology by writing an add-in for Outlook.
Python
You can use Python to scan Inbox for new emails and then execute SQL query against SQLServer.
Example
Here's the example how to filter all emails by specific word in email subject.
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")
root_folder = namespace.Folders.Item(1)
inbox = root_folder.Folders[1]
misc = inbox.Folders[0]
conn=connect(connStr)
cur=conn.cursor()
for message in misc.Items:
stats={}
if message.Subject.startswith('[PROD] IQ->Snowflake'):
stmt="Your SQL Server payload here"
cur.execute(stmt)
I have a requirement of sending emails to approximately 15,000 email addresses. Content of the email is same for all. I talked to my mail server administrator and according to him I can send only 500 emails/ hour. I wrote an utility using java mail API to achieve this. I am creating a connection(transport.connect()) and then reusing it. My utility will be running for approx 30 hours to send all 15,000 emails.
The question I have "Is there any limit on number of emails being sent per connection? And is there any time out issues I could run into? Should I close the connection and get a new connection at some interval? like after sending 100 emails or after 1 hour?"
The answers to all your questions depend on your mail server, not on JavaMail. Talk to your mail server administrator again.
I have a SQL Server job that sends out a notification every time it fails. I run this job every 5 minutes. If something the job needs has its state changed at 10:00 PM at night and the problem isn't discovered until the next morning, there would be over 100 e-mails sent with the same failure notification.
Is there anyway for you to throttle the number of e-mails sent? For example, I would like SQL Server to send out an e-mail notification on the hour if any of the 12 scheduled runs during the hour fails, but no more than one e-mail should be sent (even if there are multiple failures).
You could create a simple table with the job name and a bit column indicating whether an email has been sent successfully, then check that column as part of the alert.
DECLARE Notifications TABLE
(
ID int IDENTITY (1, 1) PRIMARY KEY NOT NULL,
JobName varchar(50),
MailSent bit DEFAULT 0
)
In SSMS select Database Mail under Management, right-click and Configure Database Mail. After that's complete send a test mail using the new profile to confirm that works.
Next, open the properties of the SQL Server Agent. On the Alert System page enable the mail profile. Restart the SQL Server Agent for the change to take effect.
Under the SQL Server agent create Operators to send messages to.
Finally, in your job select Notifications and set the Operator to send to when the job completes.
Can I ask what is the difference between xp_sendmail and sp_send_dbmail proc? They are both send e-mail message, which may include a query result set attachment, to the specified recipients.....
What is the difference?
xp_sendmail requires a MAPI client installed, such as Outlook, on the server. This is the only option for SQL Server 2000 and before.
sp_send_dbmail is a simple SMTP solution, added for SQL Server 2005+
sp_send_dbmail is by far better.
Another difference between the two is that email message sent using sp_send_dbmail() will be rolled back (not sent) if the transaction is rolled back. This does not happen with email sent using xp_sendmail().
So, if you want the email message to be sent regardless of the end result of the transaction you'll need to use xp_sendmail().
I was sending emails to notify users if an SP was unable to complete it's processing. Of course, I was rolling back the transaction in that event. When I switched to sp_send_dbmail() the transactions that were being rolled back (the very ones I wanted to get an email notification from) stopped sending emails.
we don't control the calling code - it's closed and calls the sp in a transaction. We need a feature in SQL Server to send direct or flush the mail queue.