|
| Author |
Message |
Silmar
Joined: 05 Aug 2007 Posts: 5
|
Posted: Mon Jan 28, 2008 6:39 pm Post subject: EventSink, VBScript and mail sending |
|
|
On Exchange 2003 I created COM+ Application, as it's identity I set domain
account which is member of domain admins. Then I created a VBScript event
sink which I registered using Exchange Explorer in public folder. It's fired
by OnSave events, and if it's body I set logging to local file it works but
when I set it to send emails it fails. If I run the same script from command
line the email is sent. If I add to this script some entries making it to
use remote SMTP to send mails it also works - even as event sink.
So why I cannot send emails from event sink using local SMTP?
Regards
Silmar
Archived from group: microsoft>public>exchange>development |
|
| Back to top |
|
 |
Glen Scales [MVP]
Joined: 05 Aug 2007 Posts: 92
|
Posted: Tue Jan 29, 2008 2:13 pm Post subject: Re: EventSink, VBScript and mail sending |
|
|
What does your code look like ?. Are you trying to use the drop directory or
port 25 ? Have you got protocol logging enabled on the server this will
generally tell you why an attempt to send a message is failing.
Antivirus/AntiSpam software on the local box have you check the logs ?
Cheers
Glen
"Silmar" wrote in message @microsoft.com...
> On Exchange 2003 I created COM+ Application, as it's identity I set domain
> account which is member of domain admins. Then I created a VBScript event
> sink which I registered using Exchange Explorer in public folder. It's
> fired by OnSave events, and if it's body I set logging to local file it
> works but when I set it to send emails it fails. If I run the same script
> from command line the email is sent. If I add to this script some entries
> making it to use remote SMTP to send mails it also works - even as event
> sink.
>
> So why I cannot send emails from event sink using local SMTP?
>
> Regards
> Silmar |
|
| Back to top |
|
 |
Silmar
Joined: 05 Aug 2007 Posts: 5
|
Posted: Tue Jan 29, 2008 4:26 pm Post subject: Re: EventSink, VBScript and mail sending |
|
|
My code is below. The two commented lines in the beginning and the one at
the end I use while checking this script from commandline (in that case I
also comment "script" and "sub" lines in the begginig and at the end).
First I tried to use default SMTP, then I added lines which configured
remote one, then I specified in them local SMTP. In every case when run from
command line script worked, when run as event sink it succeeded only with
remote SMTP.
On production Exchange there is Antigen, but in testing environment it's
just Exchange.
Regards
Silmar
Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags)
Set objMap = CreateObject("exoledb.urlmapper")
Set objMessage = CreateObject("CDO.Message")
Set objConnection = CreateObject("ADODB.Connection")
Set objRecord = CreateObject("ADODB.Record")
' bstrURLItem =
objMap.HttpUrlToFilePath("http://172.22.23.202/public/EventSink/{162DF157-6066-40D5-9DA3-FA2E1ED900CA}.EML")
' bstrURLItem = objMap.FilePathToExoledbFileUrl(bstrURLItem)
strHTTPPath = objMap.ExoledbFileUrlToFilePath(bstrURLItem)
strHTTPPath = objMap.FilePathtoHttpUrls(strHTTPPath)(0)
strHTTPPath = LCase(strHTTPPath)
strURL = strHTTPPath & "?cmd=Open"
With objConnection
' Create ADO connection
.ConnectionString = bstrURLItem
.Provider = "Exoledb.DataSource"
.Open
' Open ADO record
Err.Clear
objRecord.Open bstrURLItem, objConnection, 3
strHTMLBody = ""
strHTMLBody = strHTMLBody & "A new item has been
submitted."
strHTMLBody = strHTMLBody & "Click the following link to open the item
with your Web browser " &
objRecord.Fields.Item("urn:schemas:httpmail:subject").Value & ""
strHTMLBody = strHTMLBody & ""
With objMessage
' Originator
.From = "suser@pl.ing-ad"
' Recipient, either a user or a group
.To = "silmar@pl.ing-ad"
.Subject = "Nowa rezerwacja dla Salka_Parter"
.AutoGenerateTextBody = True
.HTMLBody = strHTMLBody
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "172.22.23.202"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 1025
.Configuration.Fields.Update
.Send
End With
End With
' MsgBox ("KONIEC")
End Sub
|
|
| Back to top |
|
 |
Silmar
Joined: 05 Aug 2007 Posts: 5
|
Posted: Tue Jan 29, 2008 4:38 pm Post subject: Re: EventSink, VBScript and mail sending |
|
|
You mentioned drop directory, how it can be used to send mails?
Regards
Silmar |
|
| Back to top |
|
 |
Silmar
Joined: 05 Aug 2007 Posts: 5
|
Posted: Tue Jan 29, 2008 5:10 pm Post subject: Re: EventSink, VBScript and mail sending |
|
|
Of course in above code port 1025 for SMTP is because I created new virtual
SMTP server on Exchange and set it to listen on 1025. Unfortunatelly it also
didn't help.
Regards
Silmar |
|
| Back to top |
|
 |
Glen Scales [MVP]
Joined: 05 Aug 2007 Posts: 92
|
Posted: Wed Jan 30, 2008 3:06 pm Post subject: Re: EventSink, VBScript and mail sending |
|
|
Have you tried enabling Protocol logging on the SMTP server this will at
least tell you if its trying to send the email and failing for some reason.
The other thing is you have no error checking in your script so if an error
is being generated there is really no way to tell. You might want to try
adding a on error resume next and then adding some code to check if any
error codes are generated after particular statements and write these out to
a text file.
The default for CDOSYS when you don't specify a configuration setting is
that it will use the pickup directory eg C:\Program
Files\Exchsrvr\Mailroot\vsi 1\pickup to send email.
The other option in a Event sink you already have a Exoledb connection open
to the Exchange store so just send the message via Exoledb eg
http://msdn2.microsoft.com/en-us/library/ms875947.aspx
Cheers
Glen
"Silmar" wrote in message @microsoft.com...
> Of course in above code port 1025 for SMTP is because I created new
> virtual SMTP server on Exchange and set it to listen on 1025.
> Unfortunatelly it also didn't help.
>
> Regards
> Silmar |
|
| Back to top |
|
 |
Silmar
Joined: 05 Aug 2007 Posts: 5
|
Posted: Mon Feb 04, 2008 7:34 pm Post subject: Re: EventSink, VBScript and mail sending |
|
|
> So why I cannot send emails from event sink using local SMTP?
Finally a few days ago I found an answer. Regardless of the method: pickup
folder, SMTP or Exchange, rights for pickup directory are required. In
default installation it is C:\Program Files\Exchsrvr\Mailroot\vsi 1\PickUp,
and it is enough to add create files permission for user who is set as an
identity for COM+ application which was created for running VBscript event
sinks.
Regards
Silmar
|
|
| Back to top |
|
 |
|