Re: SMTP Protocol Event Sink to prevent mail from being sent
From: Victor Ivanidze (no_at_spam.please)
Date: 12/15/04
- Next message: Alberto: "Event ID 3011"
- Previous message: Dane: "Repeated inbound SMTP failure (timeout) from specific domains"
- In reply to: Chris Rose: "SMTP Protocol Event Sink to prevent mail from being sent"
- Next in thread: Chris Rose: "Re: SMTP Protocol Event Sink to prevent mail from being sent"
- Reply: Chris Rose: "Re: SMTP Protocol Event Sink to prevent mail from being sent"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Dec 2004 16:38:14 +0300
Try to use another event:
STDMETHODIMP CSink::OnMessagePostCategorize(
IMailMsgProperties *pMailMsg,
IMailTransportNotify *pINotify,
PVOID pvNotifyContext)
--
Regards,
Victor Ivanidze,
software developer
www.ivasoft.biz
"Chris Rose" <ChrisRose@discussions.microsoft.com> wrote in message
news:E1E7F3F1-0769-46E5-8456-C3A86B2458B0@microsoft.com...
> Hye,
>
> As a simple proof of concept I want to delete any outbound mail that is
sent
> from either Outlook or SMTP client if the subject does not contain the
word
> "Agreed".
>
> The following (VB COM DLL) Transport Event Sink works fine, so long as I
> install it on a second Virtual SMTP server so that Outlook mail is relayed
to
> it in SMTP format.
>
>
> Implements CDO.ISMTPOnArrival
>
> Private Sub ISMTPOnArrival_OnArrival(ByVal Msg As CDO.Message, EventStatus
> As CDO.CdoEventStatus)
>
> Dim flds As ADODB.Fields
>
> Set flds = Msg.EnvelopeFields
>
> If Not InStr(Msg.Subject, "Agreed") > 0 Then
>
>
> flds("http://schemas.microsoft.com/cdo/smtpenvelope/messagestatus").Value
=
> cdoStatAbortDelivery
> flds.Update
>
> Msg.DataSource.Save
>
> sSender = Msg.From
>
> Dim oRejectionMessage As CDO.Message
> Set oRejectionMessage = CreateObject("CDO.Message")
> oRejectionMessage.To = sSender
> oRejectionMessage.From = "MAILconsent"
> oRejectionMessage.Subject = "Acceptable MAIL Usage Policy"
> oRejectionMessage.TextBody = "Please read and agree to the policy
> first."
> oRejectionMessage.Send
> Set oRejectionMessage = Nothing 'release the object reference
>
> End If
>
> End Sub
>
>
> I don't really want to have a second SMTP server, so I decided to look
into
> Protocol Events instead as I learnt that GFI adds disclaimers in this way.
I
> implemented this in C#. The event fires for both Outlook and SMTP clients
> which is exactly what I want, however I am unable to delete the message.
Both
> the AbortDelivery or BadMail message status' are ignored and the mail is
> delivered.
>
> If I change the Recipients List to a known different recipient the mail is
> delivered to the changed recipient so I know that I am kind of on the
right
> tracks. If I clear the list of recipients the mail is queued indefinitely
and
> seems to hold up all other mail.
>
> Here is the C# code:
>
> // registered for OnMessageStart event with the rule "mail from=*"
> [Guid("679CD792-463D-4c9f-B47B-D997A67B97C4")]
> public class SampleOutboundSink : ISmtpOutCommandSink
> {
> void ISmtpOutCommandSink.OnSmtpOutCommand(
> object server,
> object session,
> MailMsg message,
> ISmtpOutCommandContext context)
> {
> MailMsgPropertyBag Sever = new MailMsgPropertyBag(server);
> MailMsgPropertyBag Session = new
MailMsgPropertyBag(session);
> Message Msg = new Message(message);
> SmtpOutCommandContext Context = new
> SmtpOutCommandContext(context);
>
> String strMessage;
> if (Msg.Rfc822MsgSubject != null)
> strMessage = Msg.Rfc822MsgSubject.ToString();
> else
> strMessage = "";
>
> // if not Agreed then do not send mail
> if (strMessage.IndexOf("Agreed") == -1) {
> // create a blank list of recipients to stop this
> mail from being
> // delivered
> //RecipsAdd newRecips = Msg.AllocNewList();
> //newRecips.AddSMTPRecipient("");
> //Msg.WriteList(newRecips);
>
> Msg.MessageStatus =
> Message.MessageStatusEnum.BadMail;
> Msg.Commit();
> }
>
> Context.CommandStatus = (uint)
ProtocolEventConstants.S_OK;
>
> }
> }
>
>
> Any help on this would be greatly appreciated. And I apologise for posting
a
> similar message earlier in the Exchange 2000 Development forum.
>
> Regards,
>
> Chris.
>
- Next message: Alberto: "Event ID 3011"
- Previous message: Dane: "Repeated inbound SMTP failure (timeout) from specific domains"
- In reply to: Chris Rose: "SMTP Protocol Event Sink to prevent mail from being sent"
- Next in thread: Chris Rose: "Re: SMTP Protocol Event Sink to prevent mail from being sent"
- Reply: Chris Rose: "Re: SMTP Protocol Event Sink to prevent mail from being sent"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading