Link to home
Create AccountLog in
Avatar of meteorelec
meteorelecFlag 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

Avatar of kenpem
kenpem
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of 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
Avatar of kenpem
kenpem
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer