exchangefreaks.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

EventSink, VBScript and mail sending

 
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Development
Author Message
Silmar



Joined: 05 Aug 2007
Posts: 5

PostPosted: Mon Jan 28, 2008 6:39 pm    Post subject: EventSink, VBScript and mail sending Reply with quote

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
View user's profile Send private message
Glen Scales [MVP]



Joined: 05 Aug 2007
Posts: 92

PostPosted: Tue Jan 29, 2008 2:13 pm    Post subject: Re: EventSink, VBScript and mail sending Reply with quote

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
View user's profile Send private message
Silmar



Joined: 05 Aug 2007
Posts: 5

PostPosted: Tue Jan 29, 2008 4:26 pm    Post subject: Re: EventSink, VBScript and mail sending Reply with quote

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
View user's profile Send private message
Silmar



Joined: 05 Aug 2007
Posts: 5

PostPosted: Tue Jan 29, 2008 4:38 pm    Post subject: Re: EventSink, VBScript and mail sending Reply with quote

You mentioned drop directory, how it can be used to send mails?

Regards
Silmar
Back to top
View user's profile Send private message
Silmar



Joined: 05 Aug 2007
Posts: 5

PostPosted: Tue Jan 29, 2008 5:10 pm    Post subject: Re: EventSink, VBScript and mail sending Reply with quote

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
View user's profile Send private message
Glen Scales [MVP]



Joined: 05 Aug 2007
Posts: 92

PostPosted: Wed Jan 30, 2008 3:06 pm    Post subject: Re: EventSink, VBScript and mail sending Reply with quote

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
View user's profile Send private message
Silmar



Joined: 05 Aug 2007
Posts: 5

PostPosted: Mon Feb 04, 2008 7:34 pm    Post subject: Re: EventSink, VBScript and mail sending Reply with quote

> 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
View user's profile Send private message
Display posts from previous:   
Related Topics:
Using VBScript to populate the From field? Hello, I have a custom form that generates an email when a task is completed. I notice the "From" field is read only when composing the message in VBScript, but I need to set the "from" field. If it's impossible, I can always have the user drag and drop t

Programmaticlly move folders between diffrent mail boxes Hi I have a solution where I want to move mails between diffrent mailboxes. The flow for a mail is. That it arrives to a group mail and someone looks at it and sets diffrent kinds of metadata. A program shall them based on this metadata move the mail to d

IIS Virtual SMTP EventSink Hi, I am going to write a EventSink program on the Virtual SMTP Server on IIS. The script is to wrtie the email subject & body to Windows EventLog And I want it to apply to all incoming emails. Right now the script is written as show below.

Send mail replies using WebDAV Hi, I'm writing an ASP.NET application where I'm required to read emails from our exchange server and also send replies to some of the messages. I'm using WEBDAV to connect to the Exchange Server. I'm able to read emails and also send new emails from my a

Porting mail routing DLL to SMTP Event Sink I'm porting an old exchange server 5.5 mail routing DLL to a SMTP Event Sink. The plan is to keep the existing code and wrap the call to with a interface. All is going well except that I can't find any documentation on th
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group