Re: SMTP OnArrival Transport Event Sink
- From: joe <joe@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 10 Aug 2005 10:58:26 -0700
When I tried the msg.reply it didn't work. Instead what I ended up doing was
have the script extract the sender list, and the recipient list. Based on
the recipient list, I send back a message using the method of sending mails
through an smtp server. A copy of my code is listed below, and it works just
fine when it runs on a windows 2003 server with the smtp service enabled.
Exchange is not even needed. Thanks for all your help.
<SCRIPT LANGUAGE="VBSCRIPT">
'This script automatically replies to incoming mails being
'sent to a specific mailbox from outside since automatic replies to the
internet is disabled
'------------------------------------------------------------------------------
Const Reciplist="careers@xxxxxxxxxx"
Sub IEventIsCacheable_IsCacheable()
'To implement the interface, and return S_OK implicitly
End Sub
Sub ISMTPOnArrival_OnArrival(ByVal objMessage, EventStatus)
' Initialize error checking
On Error Resume Next
' Declare variables
Dim strSender ' As String
Dim StrRecipient ' As String
Dim objFields ' As ADODB.Fields
' Get fields collection of message
Set objFields = objMessage.EnvelopeFields
With objFields
' Check sender
strSender =
LCase(.Item("http://schemas.microsoft.com/cdo/smtpenvelope/senderemailaddress").Value)
strRecipient =
LCase(.Item("http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist").Value)
If InStr(strRecipient, Reciplist) <> 0 Then
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "careers@xxxxxxxxxx"
objEmail.To = strSender
objEmail.Subject = "Thank you"
objEmail.Textbody = "We have received your recent inquiry concerning
employment with company"
objEmail.Send
End If
End With
Set objFields = Nothing
End Sub
</SCRIPT>
"m.piceni@xxxxxxxxxxxxxxxx" wrote:
> Hi Joe,
>
> have you tryed to create the objEmail like this:
>
> Set objEmail = Msg.Reply
>
> instead of creating it from scratch via CDO as you did in your code ? I made
> some testing replying in this way and works fine.
>
> By the way, to achieve your purpose you may also create a Server-side rule
> on your mailbox(es). You can simply use Outlook to do this. A Server-side
> rule doesn't need Outlook to function, you just need Outlook to create (or
> modify) the rules.
>
> Massimo.
>
> "joe" <joe@xxxxxxxxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
> news:43D5E0F3-E514-4758-8EC9-67131E3F0315@xxxxxxxxxxxxxxxx
> > Thank you for sharing your code. I really appreciate that.
> >
> > You see in my Exchange 2003 environment automatic replies to the internet
> > is disabled, but I have two mailboxes in the environment for which I need
> to
> > enable automatic replies to the internet. I heard that I would have to
> write
> > an exchange
> > event sink, and that is when I decided to investigate writing event sink.
> > I am going to try to do a recipient filter, and if the mail is going to
> those
> > two mailboxes, I want the exchange server to automatically reply with a
> > specific message to the sender of the message. Having the server reply
> is
> > the part that I am having a hard time with. I spent six hours last night
> > trying to figure it out, and still I could not pull it off. My code is
> > listed below. Thanks.
> >
> > <SCRIPT LANGUAGE="VBScript">
> >
> > Set objEmail = CreateObject("CDO.Message")
> >
> > Sub IEventIsCacheable_IsCacheable()
> > 'To implement the interface, and return S_OK implicitly
> > End Sub
> >
> > Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus)
> > Dim envFlds
> > Dim iFound
> > Set envFlds = Msg.EnvelopeFields
> >
> > 'identifying the sender so an e-mail can be sent back
> >
> > sender=msg.from
> >
> > 'condition to if the mail is going to the careers mailbox
> >
> > If Msg.to= "careers@xxxxxxxx" Then
> >
> > objEmail.From = "careers@xxxxxxxx"
> > objEmail.To = sender
> > objEmail.Subject = "Thank you"
> > objEmail.Textbody = "We have received your resume, and we will review it.
> > We will contact you."
> > objEmail.Send
> > End If
> >
> > End Sub
> >
> >
> > </SCRIPT>
> >
> >
> >
> > "m.piceni@xxxxxxxxxxxxxxxx" wrote:
> >
> > > Hi Joe,
> > >
> > > at the moment I'm just making some testing with a very simple VBS script
> > > that logs the messages and deletes them. Here it is, but it's not so
> clever
> > > and not commented at all (don't try it in your production
> environment!!!):
> > >
> > > <SCRIPT LANGUAGE="VBScript">
> > >
> > > Const cdoRunNextSink = 0
> > > Const cdoSkipRemainingSinks = 1
> > > Const cdoStatAbortDelivery = 2
> > > Const cdoStatBadMail = 3
> > >
> > > Sub ISMTPOnArrival_OnArrival(ByVal Msg, EventStatus )
> > > Dim fs
> > > Set fs = CreateObject("Scripting.FileSystemObject")
> > > Dim file
> > > Set file = fs.OpenTextFile("E:\exchserv\EventSink\sinktest.txt", 8,
> True )
> > > file.Write "From: " & Msg.From & vbCrLf
> > > file.Write "To: " & Msg.To & vbCrLf
> > > file.Write "Subject: " & Msg.Subject & vbCrLf & vbCrLf
> > > file.Write Msg.TextBody & vbCrLf & vbCrLf
> > > file.Close
> > >
> > >
> Msg.EnvelopeFields.Item("http://schemas.microsoft.com/cdo/smtpenvelope/messa
> > > gestatus").Value = cdoStatAbortDelivery
> > > Msg.EnvelopeFields.Update
> > > EventStatus = cdoSkipRemainingSinks
> > > End Sub
> > > </SCRIPT>
> > >
> > > To register it, you can do something like this (you'll need the
> smtpreg.vbs
> > > from Exchange SDK):
> > > cscript smtpreg.vbs /add 1 onarrival SinkTest CDO.SS_SMTPOnArrivalSink
> > > "rcpt to=*@example.com"
> > > cscript smtpreg.vbs /setprop 1 onarrival SinkTest Sink ScriptName
> > > "e:\exchserv\EventSink\logsink.vbs"
> > >
> > > You may need to change path and name of the script and the rule. I use
> > > *@example.com for testing because example.com is a domain that doesn't
> > > exists (if I make mistakes, I'm sure not to spam anyone!!!).
> > >
> > > To unregister:
> > >
> > > cscript smtpreg.vbs /remove 1 onarrival SinkTest
> > >
> > > If you like VBS for making transport event sinks, take a look at this:
> > > http://playground.doesntexist.org/
> > > At the bottom of Download page there's an interesting collection of
> > > Transport Event Sink scripts.
> > >
> > > Enjoy.
> > >
> > > Massimo.
> > >
> > > "Joe" <Joe@xxxxxxxxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
> > > news:8740149C-0BF0-4F4E-B840-9014DA936A0A@xxxxxxxxxxxxxxxx
> > > > If you don't mind me asking could you post your code. I am trying to
> > > write
> > > > an event sink which would automatically reply after an e-mail is sent
> to
> > > an
> > > > address, but I have not been successful. Thanks.
> > > >
> > > >
> > > > "m.piceni@xxxxxxxxxxxxxxxx" wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I'm trying to implement a transport event sink to respond to
> messages
> > > sent
> > > > > to a particular external e-mail address (let's say
> name@xxxxxxxxxxx). I
> > > > > register the sink with the rule "rcpt to=name@xxxxxxxxxxx" and found
> out
> > > > > that the sink is invoked if I send a message directly to
> > > name@xxxxxxxxxxx,
> > > > > but is not invoked if I send it to a Contact created in Active
> Directory
> > > > > (even if the message is delivered correctly). I guess this happens
> > > because
> > > > > the sink rule is checked before the contact is resolved in its SMTP
> > > address.
> > > > > Infact, looking at the SMTP log, I see that the recipient address is
> in
> > > the
> > > > > AD LDAP format in the first entries and in SMTP format only on
> latest
> > > > > entries.
> > > > > Is there any way to intercept both the events ?
> > > > >
> > > > > Thanks.
> > > > >
> > > > > Massimo.
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
> > >
>
>
>
>
.
- References:
- SMTP OnArrival Transport Event Sink
- From: m.piceni
- RE: SMTP OnArrival Transport Event Sink
- From: Joe
- Re: SMTP OnArrival Transport Event Sink
- From: m.piceni
- Re: SMTP OnArrival Transport Event Sink
- From: joe
- Re: SMTP OnArrival Transport Event Sink
- From: m.piceni
- SMTP OnArrival Transport Event Sink
- Prev by Date: WebDAV SEARCH returns frameset html not XML
- Next by Date: Re: ADODB stream writes a unicode header
- Previous by thread: Re: SMTP OnArrival Transport Event Sink
- Next by thread: Re: SMTP OnArrival Transport Event Sink
- Index(es):
Relevant Pages
|