Re: SMTP Protocol Event Sink to prevent mail from being sent
From: Victor Ivanidze (no_at_spam.please)
Date: 12/16/04
- Previous message: Jeff Thibodeau [MS]: "RE: Smtp Authentication message with event id 1708"
- In reply to: Chris Rose: "Re: 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: Thu, 16 Dec 2004 09:10:57 +0300
Chris,
OnMessagePostCategorize event is fired on my Exchange 2000 server machine
when message is sent from Outlook to external Internet recipient.
--
Thanks and regards,
Victor Ivanidze,
software developer
www.ivasoft.biz
> Victor,
>
> Thanks but OnMessagePostCategorize is a Transport Event in the same family
> as OnMessageSubmission and these don't appear to be firing on my exchange
> 2000 server when mail is sent from Outlook (please let me know if you have
> experienced different behaviour). Transport events do fire when I use
telnet.
>
> The Protocol Events such as OnMessageStart do get fired for Outlook mail,
so
> I need to somehow delete the message using one of these protocol events.
>
> Regards,
>
> Chris.
>
> "Victor Ivanidze" wrote:
>
> > 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.
> > >
> >
> >
> >
- Previous message: Jeff Thibodeau [MS]: "RE: Smtp Authentication message with event id 1708"
- In reply to: Chris Rose: "Re: 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