Avatar of meteorelec
meteorelec
Flag for Ireland asked on

Performance Issue with XP_SMTP_SENDMAIL

It takes 15sec to send a single email using this stored procedure,
i'm looking to send out over 2000 emails using a cursor,
This would take over 8hours,
whilst with the xp_sendmail its practically instant,
Can you see why this would be?
I've attach my code below (i am sending from my exchange server on my network)
 
declare @rc int
exec @rc = master.dbo.xp_smtp_sendmail
	@FROM			= N'autoemail@meteorelectrical.com',
	@FROM_NAME		= N'Automated Email',
	@TO			= N'eoin.conway@meteorelectrical.com',
	@subject		= N'Hello HTML SQL Server SMTP Mail',
	@message		= N'<HTML><H1>this is some content for the body part object</H1></HTML>',
	@type			= N'text/html',
	@server 		= N'EXCHANGESRV'
select RC = @rc

Open in new window

Microsoft SQL Server

Avatar of undefined
Last Comment
kenpem

8/22/2022 - Mon
kenpem

if you remove the mail-sending code from the process, and just allow it to run through the cursor doing everything else (if anything), how long does it take? Answering that question will narrow the field and tell us whether the bottleneck is in the mail-sending bit or not.
meteorelec

ASKER
I remove the @message param an it is still just as slow,

To keep things simple i am working from the code attached above and i am not using a cursor,

it takes 15sec to send one email.
ASKER CERTIFIED SOLUTION
kenpem

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61