Automatically sending and tracking encrypted e-mails. How?

B

Bila

Hello,

I need to write a small application (C#, .NET 3.5), preferably as
Outlook add-in, that would be able to distribute e-mails with
personalized content to several thousand employees of the company
(internal distribution only). Since the content is sensitive and
contains confidential information all mails need to be encrypted and
possibly signed. Outlook clients of all users are set-up to use
Microsoft Outlook Native encryption/signing. Certificates with public
keys for all users are accessible through LDAP so it is not a problem
to encrypt e-mail content with appropriate certificates, even manually
if required.
A further strict request is that all sent mails need to be "tracked"
and checked for successful delivery so that a detailed status report
can be generated after the mailing batch finishes.

My question is: what would be the most straightforward way to fulfill
these requirements, preferably (but not necessarily) by using already
provided Outlook functionality?

I have tried several approaches already (which I won't list here now
because they could possibly be misleading) but all had their
shortcomings. I'd appreciate to hear some comments/ideas/concept
suggestions from experts in this field and get some pointers to the
right direction.

I will provide further information if requested.

Thank you.

Kind regards,
Mario Bilic
 
K

Ken Slovak - [MVP - Outlook]

You can't really force signing or encrypting using code, but you can set the
OriginatorDeliveryReportRequested property of a MailItem to force sending
delivery notices.

Other than that I'm not sure what you're asking for.
 
B

Bila

Hi,

thank you for your reply.

Now to clarify the problems a bit more.

1. Mail encryption and sending:

So now it's clear that encryption can not be enabled programmaticaly
when using MailItem objects but only by displaying the corresponding
Inspector object and then "pushing" the "Encrypt Message" button. Too
bad.
I have chosen a different route by using X509Certificate2 class object
for certificate handling, System.Net.Mail.MailMessage for e-mail
composition and System.Net.Mail.SmtpClient for e-mail sending. Is
there any other way to do this task, preferably one that is more bound
to Outlook so that I can work within Outlook user context instead of
explicitly doing user authentication and credentials management (which
is required for SmtpClient class)?

2. Tracking the delivery status of sent mails

As far as I have out by reading various texts on the web, the only way
to do this is by checking bounce mails, that is report mails.
Current work flow is that after I send all the mails, after a certain
period of time I scan the Inbox to check for report mails by using
ReportItem class (Microsoft.Office.Interop.Outlook). Problem here is
how to bind a sent mail with a corresponding report. A simple idea is
to place a unique ID in the Subject of the sent mail which can later
be used to match it with the subject of the report mail. Is there any
other way of accomplishing this, one that is more elegant and not so
verbose?
Another issue is how to distinguish the type of the ReportItem to know
what exactly happened (Read, Delivered, Undeliverable)? I used the
OutlookSpy tool with "IMessage->GetRecipientTable" to inspect
different ReportItem objects and noticed that they differ in certain
MAPI tags they contain. For example, undelivered mail reports have
PR_NDR_XXX tags while the ones for delivered mails don't have them but
do have PR_DELIVER_TIME. Is this sufficient to distinguish different
ReportItem types (I do not want to parse the content)? If so, how can
I extract those tags programatically (using Redemption, CDO or
whatever else)?

I apologize if my questions seem weird or sensless but this is my
first contact with MAPI/Outlook/SMTP and mailing techologies in
general so I'm just trying however I can to solve the task assigned to
me.

Thanks once again.

Regards,
Mario Bilic
 
K

Ken Slovak - [MVP - Outlook]

As far as #1 goes, if you use .NET mail classes that has nothing to do with
Outlook and is better addressed somewhere else. I have no idea about that
stuff. Executing a CommandBarButton for encryption is about the only way to
do that in code using Outlook, but you previously said that you were willing
to let the users do it manually. So either way.

I don't think that bounces is any realistic way to go. You cannot rely on
that. I have my server set not to send bounce messages and a lot of Exchange
admins I know also set their servers that way. So totally unreliable is how
I'd describe that. You also said earlier that you were only sending emails
internally so what do Internet bounce messages have to do with that? Use the
property I mentioned to earlier.
 
B

Bila

As far as #1 goes, if you use .NET mail classes that has nothing to do with
Outlook and is better addressed somewhere else. I have no idea about that
stuff. Executing a CommandBarButton for encryption is about the only way to
do that in code using Outlook, but you previously said that you were willing
to let the users do it manually. So either way.
OK, I might have not explained it properly. Under "manually if
required" I meant doing encryption by hand, that is, adding additional
code to handle certificate retrieval via LDAP and e-mail content
encryption instead of letting outlook handle everything automatically.
The end user must not take any additional actions or see any windows
or messages coming from Outlook or whatever else besides my app during
mail sending. Process must be fully automatic. In any case, it's clear
that I need to dump Outlook for this part.
I don't think that bounces is any realistic way to go. You cannot rely on
that. I have my server set not to send bounce messages and a lot of Exchange
admins I know also set their servers that way. So totally unreliable is how
I'd describe that. You also said earlier that you were only sending emails
internally so what do Internet bounce messages have to do with that? Use the
property I mentioned to earlier.
The property is already being used (or similar delivery report
requests when using .NET classes from System.Net.Mail.*) so I am
getting all delivery reports I need, that is not the issue here. What
I am asking is:
- how to programatically bind a certain delivery report to the
original e-mail that has been sent and caused that very same delivery
report to be generated.
- find out the type of the delivery report (Delivered, Read, not
delivered...).

I can iterate through delivery reports (ReportItem) objects from Inbox
but what do I need to do with them to get required information?
I really do not want to parse the delivery report content text and
extract the required information because to me that seems out right
silly. I'd like to do it in a programmatic way and what I found
through OutlookSpy is that PR_NDR_XXX, PR_DELIVER_TIME and
PR_EMAIL_ADDRESS MAPI tags should provide me all information I need.
Do you know how to extract values of those tags using C#? OutlookSpy
obviously can do it but i don't know how does it do it.
 
K

Ken Slovak - [MVP - Outlook]

If you are using Outlook 2007 you can use the new PropertyAccessor object to
access those MAPI properties. The use of PropertyAccessor is covered in the
Help for the Object Browser in Outlook 2007.

If you are using an earlier version of Outlook there is no PropertyAccessor
or any other way of accessing those properties using the Outlook object
model. You have to use an alternate API. Neither Extended MAPI (C++ or
Delphi only) or CDO 1.21 are supported for managed code. I'd use the
Redemption (www.dimastr.com/redemption) COM wrapper for Extended MAPI, which
can be used with C#. There are lots of code samples out there for using the
Fields collection of an item from Redemption.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top