Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««12345»»

Sending HTML Newsletters in a Batch Using SQL Server Expand / Collapse
Author
Message
Posted Thursday, May 27, 2010 2:15 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, May 22, 2014 8:32 AM
Points: 163, Visits: 428
Mike-1076638 (5/27/2010)
select * from subscribers where subscription_date=getdate()-365

Easy Peasy

Mike
DB Software Laboratory
ETL Tools for everybody


Well, that was my point with the purely fixed distribution list on the mailserver. I was explaining where this kind of solution is highly useful.


_______________________________________________________
Change is inevitable... Except from a vending machine.
Post #929290
Posted Thursday, May 27, 2010 5:39 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Wednesday, July 2, 2014 9:41 AM
Points: 3,433, Visits: 14,421
This then runs at a particular interval as a scheduled task and I keep our Exchange Admin from breathing down my neck.


This relates to what I was saying about Enterprise restrictions these Exchange admins have created business for Google because Google let us run Asp.net System.NET code when Enterprise Exchange Admins and Hotmail were blocking our code. Today Google GMail pro is used by many small businesses. Microsoft is fighting back Exchange online Admins are Microsoft employees.



Kind regards,
Gift Peddie
Post #929381
Posted Thursday, May 27, 2010 6:04 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, May 22, 2014 8:32 AM
Points: 163, Visits: 428
Gift Peddie (5/27/2010)
This then runs at a particular interval as a scheduled task and I keep our Exchange Admin from breathing down my neck.


This relates to what I was saying about Enterprise restrictions these Exchange admins have created business for Google because Google let us run Asp.net System.NET code when Enterprise Exchange Admins and Hotmail were blocking our code. Today Google GMail pro is used by many small businesses. Microsoft is fighting back Exchange online Admins are Microsoft employees.


I dunno, I can run any code I want. If I was to take my perfectly acceptable sql solution, export the already generated email list to another application/server to sort out and then manage the interim code, I sure as hell would want it in house rather than rely on 3rd party.

OK, google lets you run ASP code. So, your SQL job that is already run via SQL to generate other info, rather than using built in SQL Server mail functionality will what? Generate a temp table of recipients in time for a separate sheduled ASP task to read the table and communicate with google to create a sender list to send a mail?

Technically speaking I can actually create a temporary mailing group in exchange directly from SQL server but why would I want to.

"Also, on the exchange admin breathing down my neck" issue, that is only going to be a problem with small businesses who can't afford <exagerate>16 processor, quad core 64GB Exchange servers and TB leased lines</exagerate>. I know for a fact that paying for hardware, OS and Software it is a hell of a lot cheaper for us to do it in house with MS Exchange even over 2 years than it is to go corporate hosted.

Again though, that is off topic for this post. If you are sending a lot of emails via SQL Server, and the mail server balks a bit here is one suggestion as to how to batch it.

I also submitted an alternative batching solution. It may bo good, it may not be.

It would be nice to see more comments on the actual area of toppic (how to batch it)

I have not yet had a chance to do tests on the code for performance and look at it as a whole but intend to. I submitted my version as an alternative but it may be awful in comparison. It certainly has the flaw that the batch size is limited by an unknown amount depending on average email length in batch.

It's a good article, Let's discuss the article rather than the mirriad ways of sending email.


_______________________________________________________
Change is inevitable... Except from a vending machine.
Post #929387
Posted Thursday, May 27, 2010 6:24 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Wednesday, July 2, 2014 9:41 AM
Points: 3,433, Visits: 14,421
but what if it is user subscription, that chan change minute to minute, that generates the recipient list so each new user has the email address as part of the user table in sql. What if also you need a query to pick the recipients, for instance all who have signed up for over a year, ot any criteria you want.

You can have a job to check if any citeria match then generate the emails based on matching criteria all within a single SQL job without having to pass the recipient list out to another process.

Keeping it within SQL server then reduces the number of platforms that need to be maintained.


I did not say the article is not a good article but I am saying DB mail comes with paid SQL Server editions but .NET code runs in all editions. And yes all subscriptions can be automated using SQL Server Express and Windows scheduler as needed.



Kind regards,
Gift Peddie
Post #929389
Posted Thursday, May 27, 2010 6:54 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, September 7, 2011 8:38 AM
Points: 28, Visits: 96
select ...
union
select ...
union
select ...
union
select ...

This is a ridiculous construct! If you are certain you do want to use union because you want to sort and deduplicate the rows, then you should always use this construct instead:
select ...
union all
select ...
union all
select ...
union
select ...



Post #929394
Posted Thursday, May 27, 2010 8:24 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, September 24, 2012 11:02 PM
Points: 41, Visits: 38
This article tells you "how", but my question would be "why?". Why would you even want to do this?

This is a horrendous solution. It is a sequence of ugly hacks, and almost every step of the article has something that makes me cringe.

SQL Server is a database engine, not some general purpose application programming environment. Use the database to store and manipulate data. Leave the higher level stuff like constructing HTML documents and sending emails to a general purpose programming language like C#.

People who are commenting that this is a beautiful solution do not know the meaning of beauty.
Post #929414
Posted Thursday, May 27, 2010 9:53 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, January 6, 2014 1:47 AM
Points: 292, Visits: 1,084
Mike,

In my case, the table storing the email addresses of the users to whom the Newsletters were supposed to be sent was in MYSQL database.It is also not possible that the organisations will be creating a seperate relay server for sending Newsletters.It is also possible that the organisation might be using the same relay server for this purpose as well as for the corporates internal use. If yes, then sending all the Newsletters in a bulk sometimes creates a heavy load.

Satnam
Post #929431
Posted Thursday, May 27, 2010 10:06 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, September 24, 2012 11:02 PM
Points: 41, Visits: 38
My question as to "why" is not "why would you want to send in batches" (the case for this is obvious, and you made it well), but "why would you want to do it all *in SQL Server*". My criticism is of the architecture, not the idea. Use the DB for data operations. Use an application for higher level operations. Don't force it all into the DB. Just because you can do it in SQL Server, doesn't mean that you should.

I understand that on some occasions it is sometimes necessary to hack together something that works, but is not necessarily beautiful, and I am as guilty as anyone of this. The difference is, I wouldn't write an article and post it on the internet telling everyone about it.
Post #929433
Posted Thursday, May 27, 2010 10:41 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 11:30 PM
Points: 36,706, Visits: 31,156
Good article but I guess I'm missing something. Instead of sending things in batches of "x" quantity every 10 minutes, wouldn't it just be easier to send 1 email every 3 or 4 seconds?

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #929447
Posted Friday, May 28, 2010 8:26 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 28, 2011 2:03 AM
Points: 39, Visits: 145
Good solution. We have used a very similar method for a while to send out large mailing lists on a daily basis. It's very quick.
Also, we send out in the thousands via an Agent Job, 1 at a time with a slight pause in between and don't get any issues.
Post #929711
« Prev Topic | Next Topic »

Add to briefcase «««12345»»

Permissions Expand / Collapse