Storing Copies of Email Sent Via Script

Most, if not all, of the Domino systems I've developed send automated emails via server-based scripts. Normally this is by creating a NotesDocument object, making sure it has a "SendTo" field and then calling the .Send() method, which routes it via the Domino SMTP task to the intended recipient.

It's always worked well but every now and then there's the inevitable support call to say "User X says they didn't get the email about Y after doing Z".

My approach to this used to be "Hey, my duties end once when I call dot send!" and I'd explain that it's an admin issue that's "out of my hands". But I now like to help out as much as I can and will do my best to work out why no mail was received while explaining that delivery of email is as reliable as Royal Mail.

What I tend to do now when sending email via script is add a BCC to a special GMail account of mine to all emails sent. If the mail is in that account then I know it was sent and that Domino routed it out of the server (at least to my address anyway). Not ideal, but it helps get to the bottom of things.

A system I'm working on at the moment is ASP.NET based and so there's no inbuilt SMTP server. Well, there is, kind of, but I chose to use GMail's SMTP server to send mail. The C# code connects, authenticates and sends the mail via a connection to a specified port at smpt.gmail.com. All works well and you can tell via Exception catching whether it went wrong or not.

An added bonus of the GMail method is that it stores a copy of the email in the sent folder of the account used to authenticate, so I always have a record of what happened and I assume that the fact it's in that folder means it was in fact sent (whether it was received or not is a different matter, of course).

In Domino I guess you could do this if you created the NotesDocument in a dedicated Notes Mail file and save it once sent? Does that mean it was delivered though? There's nothing to say it's not dead mail in mail.box.

What's your approach to sending email and fielding calls form irate users who blame you for problems with the minefield that is email delivery?


  1. Logging is my answer - within Notes I always log a successful call to the send method as well as any errors.

    From this I can confirm its left the application - from then on if I need to confirm routing I would check the server log and after that I hand over to the administrators who would check the gateways.

    Keeping copies of emails could be a legal / compliance minefield.

      • avatar
      • Jake Howlett
      • Thu 18 Nov 2010 05:14 AM

      "Keeping copies of emails could be a legal / compliance minefield."

      On the system from which they were sent or in my own "free" mail account elsewhere? I'm guessing the latter more so than the first?

      Show the rest of this thread

    • avatar
    • Sandra Noronha
    • Thu 18 Nov 2010 05:25 AM

    One time there was an application where it was quite important for the users to receive the e-mail notifying about a new document being created for them (it had to do with cost validation).

    What I did was to break the process in two steps: first, compose the document, with all the information and recipients and save it to the database itself. Then, run trough the "unsent" mail view and process the sending - after doing doc.send, if no error occurred, I would then mark the document on the database as sent, so it would now appear on a sent mail view.

    This would allow to check if the mail had been correctly composed (no recipient or information forgotten) and if it had been sent. More, if, for some reason, it failed to send the e-mails, there was a scheduled agent trying to re-send them. And the time of the "sending" would be registered, so it would be easy to lookup for it on the server's log.

    Additionally, once a month, an agent can be run to delete (or move to a backup database) all the sent mails.

    Not perfect or bullet-proof, but it has been helpful.

    • avatar
    • Jeroen Jacobs
    • Thu 18 Nov 2010 06:03 AM

    Well, there is always the excellent mail-tracking and mail-journaling capabilities that are built in Domino.

    Especially the mail tracking will tell you the exact routing path, and if the user has deleted the mail in their inbox or not.

    For an asp.net based solution, that's a different story of course. But maybe the smtp-server you are using has a similar function too. Most smtp-servers have logging-functionality built-in.

      • avatar
      • Jake Howlett
      • Thu 18 Nov 2010 06:06 AM

      Does Domino's journalling only work on internal mail? Most of what I do sends emails to external internet addresses.

      I'm assuming with GMail that the existence of the mail in teh Sent folder means the SMTP server considers it to have been "delivered". Obviously that doesn't mean the user sees it in their inbox. That's a whole other matter.

      Show the rest of this thread

    • avatar
    • Ferdy
    • Thu 18 Nov 2010 06:39 AM


    Your approach could indeed give more traceability as for if the email was sent (although I agree with @Mark to be very careful in storing this in gmail), but that rarely ever is the problem in my experience.

    Usually the email was sent but not accepted somewhere in the mail route. If you find that acceptable as it is not your responsibility to actually *deliver* it, then you're done. If you're leaning towards guaranteed delivery, which you should as nobody cares that you sent it if it was not received, then a whole world of inconsistencies open up. Read this and wheep:


    That article does not even cover the various exceptions that may be needed per email service provider. This is why the bigger, public websites usually outsource the sending of mass emails using 3rd party services.

    • avatar
    • John Fazio
    • Thu 18 Nov 2010 07:14 AM

    You can use a dedicated mail file to store a copy and cull any NDRs but there will never be a guarantee they received it. I've had users inadvertently set up rules that automatically delete all incoming mail. We use a hybrid approach of mailing from dedicated mail files, using bcc to a central mail-in database with a retention period of 30 days, and an external account. We also use the bcc on all user generated mail from systems with workflow approval. When we get the call that the email wasn't received we just forward it from the central depository. 99 times out of 100 when they insist to know what happened we restore it from their trash. That anomalous 1 time we tell them to check the personal email account for the address stored in the originators address book.

  2. Call me crazy... but why not simply BCC a Mail-In Database that acts as an Email Transaction Log?

      • avatar
      • Jake Howlett
      • Thu 18 Nov 2010 08:15 AM

      That's just plain crazy!

  3. My method bounces between Chris's BCC and Marks logging depending on where the log needs to be visible. If it's for the users and they want it in the context of the application (my default) it gets logged there and most of my apps have a "purge" agent to clean these up, retaining the last n days of activity (typically 30). This has a problem though in that if you have a very busy database, you're flooding it with logs. In that case, tack on an aggregator that will aggregate and summarize your log documents on an hourly basis much like the Domino server log.

    BCC to mail in is a very effective way though with lots of efficiency. Cleanup can be automated via policy, logs can be secured by ACL apart from the source apps, it can be clustered with your other mail.... it's a very nice option but has the overhead of one additional app per environment which could cost your client in terms of storage on their NAS.

    1. "Cost your client in terms of storage on their NAS"

      I hear ya, but it's all about presentation:

      "Sure, this could result in an extra 100MB per year [we're talking email here...], but this way you know exactly what you're sending inside and outside of your organization."

      Using a MIDb to store and *present* your data is the more RAD and maintainable way to go IMHO.

      Show the rest of this thread

    • avatar
    • Niel Revelle
    • Thu 18 Nov 2010 08:38 AM

    I use Memo.DeliveryReport = "T" to use the Domino delivery report feature. For SMTP messages I end up with the date/time the email was delivered to the destination SMTP server.

      • avatar
      • Jake Howlett
      • Thu 18 Nov 2010 08:39 AM

      Sounds interesting. So, I guess you save the memo/document in a Mail file somewhere and the server stamps it with the date/time it was delivered?

    • avatar
    • Jens Schwendemann
    • Thu 18 Nov 2010 03:40 PM

    I second Jeroen's approach with mail journaling. Domino delivers all you need to simply create a copy of all email a router touches and securely stores it in a database on the respective server.

    I my opinion it is not an option to have the a email be bcc'd ot a gmail account that is out of the reach of the domino's servers administrator.

  4. I send a BCC copy to the admin Notes mailbox. I also store a copy of all emails on the app itself. The users can log in any time and read everything the system has sent to them. The help docs tell them to check this if they haven't received the expected status report.

    Of course this assumes all the email recipients have accounts, which is true in my app.

Your Comments


About This Page

Written by Jake Howlett on Thu 18 Nov 2010

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content