PDA

View Full Version : Email from an alert?


Coup
December 22nd 03, 09:18 PM
im trying to send an email from a perfmon alert any ideas?

I have tried this but cant seam to get it to work right... I keep getting
errors in the script...maybe there is a simpler way?


Dim Message As New CDO.Message
Dim Configuration As New CDO.Configuration
Dim Fields As ADODB.Fields
Set Fields = Configuration.Fields
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPServer) = "mail.server.net"
.Item(cdoSMTPConnectionTimeout) = 5
.Update
End With
With iMsg
Set .Configuration = Configuration
.To = szTo
.From = szFrom
.Subject = "Test Message"
.TextBody = "Message Text body"
.Send
End With
Set Message = Nothing
Set Configuration = Nothing
Set Fields = Nothing
End Sub

What am i missing and what is the proper syntax? for this script?

Mark L. Ferguson
December 22nd 03, 09:18 PM
That's not a script, it's visual basic. You want something like:

--script.vbs--
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
Dim iConf
Set iConf = CreateObject("CDO.Configuration")

Dim Flds
Set Flds = iConf.Fields

With Flds
' assume constants are defined within script file
.Item(cdoSendUsingMethod) = 2 ' cdoSendUsingPort
.Item(cdoSMTPServerName) = "
.Item(cdoSMTPConnectionTimeout) = 10 ' quick timeout
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "username"
.Item(cdoSendPassword) = "password"
.Item(cdoURLProxyServer) = "server:80"
.Item(cdoURLProxyBypass) = "<local>"
.Item(cdoURLGetLatestVersion) = True
.Update
End With

With iMsg
Set .Configuration = iConf
.To = """User A"" >"
.From = """User B"" >"
.Subject = "Hows it going? I've attached my web page"
.CreateMHTMLBody "http://mypage"
.AddAttachment "C:\files\mybook.doc"
.Send
End With
--end---

--
Mark L. Ferguson TabletPC MVP
Email address : Subject: "QZ" + anything
All email without "QZ" in the subject line will be automatically deleted.
marfer's notes for XP > http://www.geocities.com/marfer_mvp/xp_notes.htm
..

"Coup" > wrote in message
...
> im trying to send an email from a perfmon alert any ideas?
>
> I have tried this but cant seam to get it to work right... I keep getting
> errors in the script...maybe there is a simpler way?
>
>
> Dim Message As New CDO.Message
> Dim Configuration As New CDO.Configuration
> Dim Fields As ADODB.Fields
> Set Fields = Configuration.Fields
> With Fields
> .Item(cdoSendUsingMethod) = cdoSendUsingPort
> .Item(cdoSMTPServerPort) = 25
> .Item(cdoSMTPServer) = "mail.server.net"
> .Item(cdoSMTPConnectionTimeout) = 5
> .Update
> End With
> With iMsg
> Set .Configuration = Configuration
> .To = szTo
> .From = szFrom
> .Subject = "Test Message"
> .TextBody = "Message Text body"
> .Send
> End With
> Set Message = Nothing
> Set Configuration = Nothing
> Set Fields = Nothing
> End Sub
>
> What am i missing and what is the proper syntax? for this script?
>
>

Google