The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Bulk emailing with attachments question


I have an ASP.NET app part of which emails order confirmations to various people.

One thing that I need to add is to attach PDF's along with it.

Due to the nature of the app, this could be anything from 1 to e.g. 100

Obviously, there will be an email size issue as well as a speed problem on the site as the user will have to wait for the process to complete and could theoretically close the browser.

What's the best way to handle these 2 issues?

Wednesday, October 13, 2004
Is it possible to do this in an overnight batch job, rather than online ?

The answer will depend on your application and the expectations of your Users.
Wednesday, October 13, 2004
Not really. Because they are orders, the goods may have to go out the same day.
Wednesday, October 13, 2004
Create a new thread and handle it?
Carfield Yim Send private email
Wednesday, October 13, 2004
Why not kick off a thread? It is up to you how to handle failed emails - you might need to build a log that the user can check back on through the system.
Rhys Keepence Send private email
Wednesday, October 13, 2004
Yeah I was thinking about that.

Am I right in saying that if I start a thread and the user closes the browser, then it will still be running?
Wednesday, October 13, 2004
Try it and see ;-)
Wednesday, October 13, 2004
How about storing the PDF's on the server for a given amount of time (say two weeks) and emailing a link to those PDF's in the order confirmation?
Wednesday, October 13, 2004
It sounds like your primary concern is (duly) with the time it takes to complete the transaction.

What I would suggest is to store their transaction in a table or file somewhere. If it isn't already available, grab an email address from the user to use for the transaction....

Create a separate process that monitors the table/file and actually completes the attachment and email operations, then fires a confirmation (or 'there's been a problem') email to the user that initiated the transaction.

In my mind, good basic data validation at the time of the original submission should ensure that the vast majority of transactions complete as expected. If not, then I think there are other design flaws in the system. It should be reasonable to assume that the "wait" for the entire transaction to complete doesn't have to exist at all, at least to the user.

The big flaw I see to this may be email filtering... If there were a problem and your email informing them of it got filtered, they may not understand or care that it is their software that borked the process.
I am Jack's patience pommeling patent
Wednesday, October 13, 2004
I would suggest emailing a link to the PDF instead of actually sending it. That would solve both the response time issue (separate thread might still be a good idea though) and the email filtering issue.

The customer could then download it at her/his convenience.

just my SEK 0.002
Henrik Sidebäck Send private email
Thursday, October 14, 2004
Those are both excellent ideas.

I don't know how feasible the link idea is, I will have to do some investigation.

I like the idea of a separate process that handles the email sending.

I will give them a lot of thought.

Thursday, October 14, 2004
Sounds like a good use for Message Queuing.  Every time to need an email drop it in the queue and have a reader responsible for checking the queue.
Craig Erdmann Send private email
Thursday, October 14, 2004
How about: put the email into some kind of stored queue (temp directory, database table, however you want to do it), and then set up a cron job to run every hour / 10 minutes / whatever to check the queue and send out anything that needs sending.
Matt Send private email
Friday, October 15, 2004
I would suggest handling it like some of the bboard / forum software handles full-text searches.  Check out:

Enter a search term.  Basically you get a progress page that auto-refreshes to show you how far along it is.  That way the long-process is happening server side without holding a connection to the browser open (which I think would time-out if it took more than a few minutes). 

And to be able to let the user close their browser but check on the status at a later time (assuming you had tons of emails going that took a long time), you could have a link from an admin homepage or something where a user could check the status of bulk emails progress.
Nicholas Smith Send private email
Monday, October 25, 2004

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz