Click here to Skip to main content
11,931,104 members (58,976 online)
Rate this:
Please Sign up or sign in to vote.
We use a 3rd party software to send Bulk Emails. The software does not provide options to add Email addresses in BCC. However, as per Compliance Rules, it is necessary for us to add a BCC address to every Email sent. Till now, we used to relay all the Emails from that software to an intermediate server having SMTP service installed in it. We deployed a VB6 DLL on that server which functioned as an SMTP Event Sink and it ran every time the "OnArrival" event of the SMTP service was fired. The DLL added the BCC address to the mail. Every thing was running fine till now. Now, we have to upgrade those servers to Windows Server 2008 R2. I have re-written the VB6 Event Sink in C#. The code is like this:

using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using ADODB;
using CDO;
using SEOLib;
namespace OnArrivalSink
 public class CatchAll : ISMTPOnArrival, IEventIsCacheable
    void IEventIsCacheable.IsCacheable()
        //This will return S_OK by default
    void ISMTPOnArrival.OnArrival(Message msg, ref CdoEventStatus eventStatus)
        catch (Exception e)
            string errorInfo = "ERROR MESSAGE: " + e.Message + "\n" +
                "INNER EXCEPTION: " + e.InnerException + "\n" +
                "SOURCE: " + e.Source + "\n" +
                "STACK TRACE: " + e.StackTrace + "\n";
            //Write to Event Log
            EventLog evtLog = new EventLog();
            evtLog.Source = "OnArrivalSink";
            evtLog.WriteEntry(errorInfo, EventLogEntryType.Error);
        eventStatus = CdoEventStatus.cdoRunNextSink;
    private void ProcessMessage(IMessage msg)
        //Get the list of recipients that the message will be actually delivered to
        string recipientList = msg.EnvelopeFields[""].Value.ToString();
        //Add a recipient in BCC form
        recipientList = recipientList + ";";
        msg.EnvelopeFields[""].Value = recipientList;

The DLL generated by the above code was registered using RegAsm.exe and it was registered successfully. The DLL was bound with the SMTP "OnArrival" event using a VBScript provided by Microsoft and that too happened without any issues. However, the DLL is not working at all. I tried logging every step but it's as if the DLL is not functioning at all. It works fine in a Windows XP machine. So, I know the C# code is functional. We are not interested in using Microsoft Exchange Server as it is an overkill for us. Please help.
Posted 29-Apr-13 22:59pm
Edited 29-Apr-13 23:04pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

On Window 2008 R2 try using RegAsm from the 64Bit .NET folder if 32bit folder doesn't work for you.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Have you tried using the RegAsm from the 64bit directory of .NET, that worked for me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 29 Jan 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100