Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Mon, 28 Jan 2008 13:39:13 +0100,    group: microsoft.public.exchange.development        back       


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
date: Mon, 28 Jan 2008 13:39:13 +0100   author:   Silmar

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 
news:283DC12E-0585-4992-93B9-A1C5ACF7C3B1@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
date: Tue, 29 Jan 2008 09:13:26 +1100   author:   Glen Scales [MVP]

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

<SCRIPT LANGUAGE="VBScript">
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 = "<html><body>"
  strHTMLBody = strHTMLBody & "<br><b>A new item has been 
submitted.</b><br><br>"
  strHTMLBody = strHTMLBody & "Click the following link to open the item 
with your Web browser <a href=" & strURL & ">" & 
objRecord.Fields.Item("urn:schemas:httpmail:subject").Value & "</a>"
  strHTMLBody = strHTMLBody & "</body></html>"

  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
</SCRIPT>
date: Tue, 29 Jan 2008 11:26:55 +0100   author:   Silmar

Re: EventSink, VBScript and mail sending   
You mentioned drop directory, how it can be used to send mails?

Regards
Silmar
date: Tue, 29 Jan 2008 11:38:14 +0100   author:   Silmar

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
date: Tue, 29 Jan 2008 12:10:42 +0100   author:   Silmar

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 
news:6E7B8DBA-1DA0-46A0-80FC-B944E51A1C05@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
date: Wed, 30 Jan 2008 10:06:25 +1100   author:   Glen Scales [MVP]

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
date: Mon, 4 Feb 2008 14:34:36 +0100   author:   Silmar

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us