From: Bart Perrier on

"mistral" <polychrom(a)softhome.net> wrote in message
news:1170324163.624672.80610(a)a34g2000cwb.googlegroups.com...

> > On 30 ���., 23:13, "Bart Perrier" <bart_perr...(a)hotmail.com> wrote:
> >> I do this very thing with a number of jobs and have taken advantage of
> >> the
> >> Message Priority after a long hard battle to figure it out.
>
> >> Where you have the wscrpt.echo use a variable instead. Such as
> >> strEmailBody = strEmailBody & yourData. If you are using HTML then you
> >> will
> >> need to add the HTML tags as well.
>
> >> Here is the method I call to send email from one particular script.
> >> Watch
> >> out for the wordwrap.
>
> >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> Sub SendEmail
> >> Dim objEmail
>
> >> ' this is actually called to generate an HTML email and insert the HTML
> >> tags
> >> Call GenerateMessage
>
> >> Set objEmail = CreateObject("CDO.Message")
>
> >> ' these are constants defined at the begining of the script.
> >> ' you can also make the TO address a variable if you need to send
> >> different
> >> messages to different recipients.
> >> objEmail.From = FROM_ADDRESS
> >> objEmail.To = TO_ADDRESS
> >> objEmail.CC = CC_ADDRESS
> >> objEmail.BCC = BCC_ADDRESS
> >> objEmail.Subject = EMAIL_SUBJECT
> >> objEmail.HTMLBody = strEmailBody
>
> >> ' more constants at the top
> >> objEmail.Configuration.Fields.Item
> >> ("http://schemas.microsoft.com/cdo/configuration/sendusing") =
> >> SMTP_SENDUSING
> >> objEmail.Configuration.Fields.Item
> >> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
> >> SMTP_SERVER
> >> objEmail.Configuration.Fields.Item
> >> ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
> >> SMTP_SERVER_PORT
> >> objEmail.Configuration.Fields.Update
>
> >> objEmail.Send
>
> >> End Sub
>
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> >> Hope this helps.
> >> Bart
--------------------

> thanks, Bart. Not fully clear, how to interface mailing code with main
> script.

> like this:

<-- start code
Public Function sGetSomeData()
... ... ...
... ... ...
... ... ...
sGetSomeData = sSomeData
End Function
else
wscript.echo strEmailBody = strEmailBody & sGetSomeData
End If
End Function

Sub SendEmail
Dim objEmail
' this is actually called to generate an HTML email and insert the
HTML tags
Call GenerateMessage
Set objEmail = CreateObject("CDO.Message")
' these are constants defined at the begining of the script.
' you can also make the TO address a variable if you need to send
different
messages to different recipients.
objEmail.From = FROM_ADDRESS
objEmail.To = TO_ADDRESS
objEmail.Subject = EMAIL_SUBJECT
objEmail.HTMLBody = strEmailBody
' more constants at the top
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing") =
SMTP_SENDUSING
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
SMTP_SERVER
objEmail.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
SMTP_SERVER_PORT
objEmail.Configuration.Fields.Update
objEmail.Send
End Sub
-- end code -->

> Where add html tags also?

> Thanks,
> mistral
---------------------------
> Sorry about that, mistral.

> Let your results accumulate in a variable such as strEmailBody. Then plug
> that variable into the email body.I changed the email format to Text but
> you
> can do it with an HTML email, you just have to add the HTML tags to your
> variable (strEmailBody) as you go. It's a little tedious but quite
> rewarding
> =]

> Watch out for word wrap.
> ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dim objEmail, strEmailSubject, strEmailBody

> Const SEND_USING = "2"
> Const SMTP_SERVER = "" ' enter your SMTP server
> Const SMTP_PORT = "25"
> Const FROM_ADDRESS = "" ' enter your From Address
> Const TO_ADDRESS = "" ' enter your To Address

> strEmailSubject = "Your Subject"

> strEmailBody = strEmailBody & sGetSomeData() & vbCRLF
> strEmailBody = strEmailBody & sGetSomeData() & vbCRLF
> strEmailBody = strEmailBody & sGetSomeData() & vbCRLF
> strEmailBody = strEmailBody & sGetSomeData() & vbCRLF

> Set objEmail = CreateObject("CDO.Message")
>
> objEmail.From = FROM_ADDRESS
> objEmail.To = TO_ADDRESS
> objEmail.Subject = strEmailSubject
> objEmail.TextBody = strEmailBody

> ' more constants at the top
> objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
> = SEND_USING
> objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
> = SMTP_SERVER
> objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
> = SMTP_PORT
> objEmail.Configuration.Fields.Update

> objEmail.Send

> Function sGetSomeData()
> sGetSomeData = InputBox("Enter Data ", "")
> End Function
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------


Hi Bart,

The results of a my code is only one line of digits. So Text format
will be OK. I need that this code just automatically send out this
result on email, without showing any input MsgBox prompt or writing
data to hard drive. I still have problems: I am not sure how to
correctly remove showing input MsgBox prompt and writing data to hard
drive. All that code need to do is automatically send out result by
email.

mistral




I'm not sure if I understand your issue. Take exactly what I gave you, enter
the value for the constants and subject and replace what I put in
sGetSomeData with your plans for sGetSomeData. Does your sGetSomeData return
the value you want it to?


From: mistral on
On 2 Фев., 05:15, "Bart Perrier" <bart_perr...(a)hotmail.com> wrote:
> "mistral" <polych...(a)softhome.net> wrote in message
>
> news:1170324163.624672.80610(a)a34g2000cwb.googlegroups.com...

>
> > > On 30 ñÎ×., 23:13, "Bart Perrier" <bart_perr...(a)hotmail.com> wrote:
> > >> I do this very thing with a number of jobs and have taken advantage of
> > >> the
> > >> Message Priority after a long hard battle to figure it out.
>
> > >> Where you have the wscrpt.echo use a variable instead. Such as
> > >> strEmailBody = strEmailBody & yourData. If you are using HTML then you
> > >> will
> > >> need to add the HTML tags as well.
>
> > >> Here is the method I call to send email from one particular script.
> > >> Watch
> > >> out for the wordwrap.
>
> > >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >> Sub SendEmail
> > >>  Dim objEmail
>
> > >> ' this is actually called to generate an HTML email and insert the HTML
> > >> tags
> > >>  Call GenerateMessage
>
> > >>  Set objEmail = CreateObject("CDO.Message")
>
> > >> ' these are constants defined at the begining of the script.
> > >> ' you can also make the TO address a variable if you need to send
> > >> different
> > >> messages to different recipients.
> > >>  objEmail.From   = FROM_ADDRESS
> > >>  objEmail.To   = TO_ADDRESS
> > >>  objEmail.CC   = CC_ADDRESS
> > >>  objEmail.BCC  = BCC_ADDRESS
> > >>  objEmail.Subject  = EMAIL_SUBJECT
> > >>  objEmail.HTMLBody  = strEmailBody
>
> > >> ' more constants at the top
> > >>  objEmail.Configuration.Fields.Item
> > >> ("http://schemas.microsoft.com/cdo/configuration/sendusing") =
> > >> SMTP_SENDUSING
> > >>  objEmail.Configuration.Fields.Item
> > >> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
> > >> SMTP_SERVER
> > >>  objEmail.Configuration.Fields.Item
> > >> ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
> > >> SMTP_SERVER_PORT
> > >>  objEmail.Configuration.Fields.Update
>
> > >>  objEmail.Send
>
> > >> End Sub
>
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> > >> Hope this helps.
> > >> Bart
>
>  --------------------
>
> > thanks, Bart. Not fully clear, how to interface mailing code with main
> > script.
> > like this:
>
> <-- start code
>  Public Function sGetSomeData()
>  ... ... ...
>  ... ... ...
>  ... ... ...
>  sGetSomeData = sSomeData
>  End Function
>  else
>  wscript.echo strEmailBody = strEmailBody & sGetSomeData
>  End If
>  End Function
>
>  Sub SendEmail
>  Dim objEmail
>  ' this is actually called to generate an HTML email and insert the
>  HTML tags
>  Call GenerateMessage
>  Set objEmail = CreateObject("CDO.Message")
>  ' these are constants defined at the begining of the script.
>  ' you can also make the TO address a variable if you need to send
>  different
>  messages to different recipients.
>  objEmail.From   = FROM_ADDRESS
>  objEmail.To   = TO_ADDRESS
>  objEmail.Subject  = EMAIL_SUBJECT
>  objEmail.HTMLBody  = strEmailBody
>  ' more constants at the top
>  objEmail.Configuration.Fields.Item
>  ("http://schemas.microsoft.com/cdo/configuration/sendusing") =
>  SMTP_SENDUSING
>  objEmail.Configuration.Fields.Item
>  ("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
>  SMTP_SERVER
>  objEmail.Configuration.Fields.Item
>  ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =
>  SMTP_SERVER_PORT
>  objEmail.Configuration.Fields.Update
>  objEmail.Send
>  End Sub
>  -- end code -->
>
> > Where add html tags also?
> > Thanks,
> > mistral
>
> ---------------------------

> > Sorry about that, mistral.
> > Let your results accumulate in a variable such as strEmailBody. Then plug
> > that variable into the email body.I changed the email format to Text but
> > you
> > can do it with an HTML email, you just have to add the HTML tags to your
> > variable (strEmailBody) as you go. It's a little tedious but quite
> > rewarding
> > =]
> > Watch out for word wrap.
> > ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Dim objEmail, strEmailSubject, strEmailBody
> > Const SEND_USING  = "2"
> > Const SMTP_SERVER  = ""  ' enter your SMTP server
> > Const SMTP_PORT  = "25"
> > Const FROM_ADDRESS  = ""  ' enter your From Address
> > Const TO_ADDRESS  = ""  ' enter your To Address
> > strEmailSubject = "Your Subject"
> > strEmailBody = strEmailBody & sGetSomeData() & vbCRLF
> > strEmailBody = strEmailBody & sGetSomeData() & vbCRLF
> > strEmailBody = strEmailBody & sGetSomeData() & vbCRLF
> > strEmailBody = strEmailBody & sGetSomeData() & vbCRLF
> > Set objEmail = CreateObject("CDO.Message")
>
> > objEmail.From = FROM_ADDRESS
> > objEmail.To = TO_ADDRESS
> > objEmail.Subject  = strEmailSubject
> > objEmail.TextBody  = strEmailBody
> > ' more constants at the top
> > objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
> > = SEND_USING
> > objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
> > = SMTP_SERVER
> > objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
> > = SMTP_PORT
> > objEmail.Configuration.Fields.Update
> > objEmail.Send
> > Function sGetSomeData()
> >  sGetSomeData = InputBox("Enter Data ", "")
> > End Function
>
>  ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------

> Hi Bart,
>
> The results of a my code is only one line of digits. So Text format
> will be OK. I need that this code just automatically send out this
> result on email, without showing any input MsgBox prompt or writing
> data to hard drive. I still have problems: I am not sure how to
> correctly remove showing input MsgBox prompt and writing data to hard
> drive. All that code need to do is automatically send out result by
> email.

> mistral

> I'm not sure if I understand your issue. Take exactly what I gave you, enter
> the value for the constants and subject and replace what I put in
> sGetSomeData with your plans for sGetSomeData. Does your sGetSomeData return
> the value you want it to?-
----------------

ok, probably there is no luck with this script.
what exactly should go right after 'End Function' ?(how look full
code)

<-- start code
Public Function sGetSomeData()
.... ... ...
.... ... ...
.... ... ...
sGetSomeData = sSomeData

End Function



From: Bart Perrier on
I have removed all of the previous posts because I think they may be
confusing to you.

Typically Functions are added at the end of the script. I doubt this is a
requirement but it really doesn't matter, I will continue to put them at the
end of the script and for the sake of this conversation, put them at the
end. So to answer your question, What goes after End Function...nothing.

Does your Function sGetSomeData do anything? If it does, then place it in
the Function sGetSomeData in the script I will paste. If your Function
sGetSomeData does not do anyting, then you need to pick some data you want
to Get Some of.

Edits this script will need are:
SMNP_SERVER - this will be the name or IP of your SNMP server.
TO_ADDRESS - to whom you want to send this email.
FROM_ADDRESS - from whom you want the email to appear

If you Copy/Paste this script and fill in the three(3) uppercase fields
immediately above, you will receive a blank email.

If you take your Function sGetSomeData and paste it into this script, in
place of what I have, the email will contain the data you retrieved.

It is recommended that you be able to read through vbScript before you try
to productionalize one.

Last call.
Bart



Here is the script. I have split some of the lines up to discourage a
wordwrap issue.

' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim objEmail, strEmailSubject, strEmailBody, someData

Const SEND_USING = "2"
Const SMTP_SERVER = "" ' enter your SMTP server
Const SMTP_PORT = "25"
Const FROM_ADDRESS = "" ' enter your From Address
Const TO_ADDRESS = "" ' enter your To Address

strEmailSubject = "Your Subject"

strEmailBody = sGetSomeData()

Set objEmail = CreateObject("CDO.Message")

objEmail.From = FROM_ADDRESS
objEmail.To = TO_ADDRESS
objEmail.Subject = strEmailSubject
objEmail.TextBody = strEmailBody


objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") _
= SEND_USING

objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= SMTP_SERVER

objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
= SMTP_PORT

objEmail.Configuration.Fields.Update

objEmail.Send


' you need to put the content of your
' sGetSomeData into this Function
Function sGetSomeData()
sGetSomeData = someData
End Function
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




From: mistral on
On 2 ���., 21:43, "Bart Perrier" <bart_perr...(a)hotmail.com> wrote:
> I have removed all of the previous posts because I think they may be
> confusing to you.
>
> Typically Functions are added at the end of the script. I doubt this is a
> requirement but it really doesn't matter, I will continue to put them at the
> end of the script and for the sake of this conversation, put them at the
> end. So to answer your question, What goes after End Function...nothing.
>
> Does your Function sGetSomeData do anything? If it does, then place it in
> the Function sGetSomeData in the script I will paste. If your Function
> sGetSomeData does not do anyting, then you need to pick some data you want
> to Get Some of.
>
> Edits this script will need are:
> SMNP_SERVER - this will be the name or IP of your SNMP server.
> TO_ADDRESS - to whom you want to send this email.
> FROM_ADDRESS - from whom you want the email to appear
>
> If you Copy/Paste this script and fill in the three(3) uppercase fields
> immediately above, you will receive a blank email.
>
> If you take your Function sGetSomeData and paste it into this script, in
> place of what I have, the email will contain the data you retrieved.
>
> It is recommended that you be able to read through vbScript before you try
> to productionalize one.
>
> Last call.
> Bart
>
> Here is the script. I have split some of the lines up to discourage a
> wordwrap issue.
>
> ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dim objEmail, strEmailSubject, strEmailBody, someData
>
> Const SEND_USING = "2"
> Const SMTP_SERVER = "" ' enter your SMTP server
> Const SMTP_PORT = "25"
> Const FROM_ADDRESS = "" ' enter your From Address
> Const TO_ADDRESS = "" ' enter your To Address
>
> strEmailSubject = "Your Subject"
>
> strEmailBody = sGetSomeData()
>
> Set objEmail = CreateObject("CDO.Message")
>
> objEmail.From = FROM_ADDRESS
> objEmail.To = TO_ADDRESS
> objEmail.Subject = strEmailSubject
> objEmail.TextBody = strEmailBody
>
> objEmail.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/sendusing") _
> = SEND_USING
>
> objEmail.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
> = SMTP_SERVER
>
> objEmail.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
> = SMTP_PORT
>
> objEmail.Configuration.Fields.Update
>
> objEmail.Send
>
> ' you need to put the content of your
> ' sGetSomeData into this Function
> Function sGetSomeData()
> sGetSomeData = someData
> End Function
> ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------
> Does your Function sGetSomeData do anything?
The script extract some data(ASCII) from file and write this data to
hard disk or show it as MsgBox. The results is sGetSomeData =
SomeData.

mistral



From: Bart Perrier on

"mistral" <polychrom(a)softhome.net> wrote in message
news:1170545227.146523.308160(a)q2g2000cwa.googlegroups.com...
> On 2 ���., 21:43, "Bart Perrier" <bart_perr...(a)hotmail.com> wrote:
>> I have removed all of the previous posts because I think they may be
>> confusing to you.
>>
>> Typically Functions are added at the end of the script. I doubt this is a
>> requirement but it really doesn't matter, I will continue to put them at
>> the
>> end of the script and for the sake of this conversation, put them at the
>> end. So to answer your question, What goes after End Function...nothing.
>>
>> Does your Function sGetSomeData do anything? If it does, then place it in
>> the Function sGetSomeData in the script I will paste. If your Function
>> sGetSomeData does not do anyting, then you need to pick some data you
>> want
>> to Get Some of.
>>
>> Edits this script will need are:
>> SMNP_SERVER - this will be the name or IP of your SNMP server.
>> TO_ADDRESS - to whom you want to send this email.
>> FROM_ADDRESS - from whom you want the email to appear
>>
>> If you Copy/Paste this script and fill in the three(3) uppercase fields
>> immediately above, you will receive a blank email.
>>
>> If you take your Function sGetSomeData and paste it into this script, in
>> place of what I have, the email will contain the data you retrieved.
>>
>> It is recommended that you be able to read through vbScript before you
>> try
>> to productionalize one.
>>
>> Last call.
>> Bart
>>
>> Here is the script. I have split some of the lines up to discourage a
>> wordwrap issue.
>>
>> ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Dim objEmail, strEmailSubject, strEmailBody, someData
>>
>> Const SEND_USING = "2"
>> Const SMTP_SERVER = "" ' enter your SMTP server
>> Const SMTP_PORT = "25"
>> Const FROM_ADDRESS = "" ' enter your From Address
>> Const TO_ADDRESS = "" ' enter your To Address
>>
>> strEmailSubject = "Your Subject"
>>
>> strEmailBody = sGetSomeData()
>>
>> Set objEmail = CreateObject("CDO.Message")
>>
>> objEmail.From = FROM_ADDRESS
>> objEmail.To = TO_ADDRESS
>> objEmail.Subject = strEmailSubject
>> objEmail.TextBody = strEmailBody
>>
>> objEmail.Configuration.Fields.Item _
>> ("http://schemas.microsoft.com/cdo/configuration/sendusing") _
>> = SEND_USING
>>
>> objEmail.Configuration.Fields.Item _
>> ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
>> = SMTP_SERVER
>>
>> objEmail.Configuration.Fields.Item _
>> ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
>> = SMTP_PORT
>>
>> objEmail.Configuration.Fields.Update
>>
>> objEmail.Send
>>
>> ' you need to put the content of your
>> ' sGetSomeData into this Function
>> Function sGetSomeData()
>> sGetSomeData = someData
>> End Function
>> ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --------------
>> Does your Function sGetSomeData do anything?
> The script extract some data(ASCII) from file and write this data to
> hard disk or show it as MsgBox. The results is sGetSomeData =
> SomeData.
>
> mistral
>
>
>


Then you should be able to take the contents of your sGetSomeData and paste
it into this script. Assuming you are not writing to disk in sGetSomeData.

Paste your script including your email settings.