Re: EventSink, VBScript and mail sending

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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@xxxxxxxxx"

' Recipient, either a user or a group
.To = "silmar@xxxxxxxxx"
.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>

.