Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Send E-Mail

Reply
 
Old 08-12-2009   #1 (permalink)
Robert Jacobs


 
 

Send E-Mail

Thanks in advance for your help!

I have a VB script that I would like to send e-mails to internal e-
mail addresses when an error occurs. I have the error checking setup,
and currently it logs to a file - however, I would like to get it to
send an e-mail to our helpdesk when an error is encountered. The
message would never need to leave our network.

We have an SMTP server on the same subnet as well. Does anybody know
how I can send a basic e-mail from the script? I can use 3rd party
software, if required, but would like that to be a last resort.

It seems simple - contact the SMTP server and tell it to send a
message to one of the accounts it has locally... but I can't find
anything that helps.

Thanks experts!

My System SpecsSystem Spec
Old 08-12-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: Send E-Mail


"Robert Jacobs" <robertjacobsit@xxxxxx> wrote in message
news:4c48a6bf-4c31-4e20-a720-f5b8df101752@xxxxxx
Quote:

> Thanks in advance for your help!
>
> I have a VB script that I would like to send e-mails to internal e-
> mail addresses when an error occurs. I have the error checking setup,
> and currently it logs to a file - however, I would like to get it to
> send an e-mail to our helpdesk when an error is encountered. The
> message would never need to leave our network.
>
> We have an SMTP server on the same subnet as well. Does anybody know
> how I can send a basic e-mail from the script? I can use 3rd party
> software, if required, but would like that to be a last resort.
>
> It seems simple - contact the SMTP server and tell it to send a
> message to one of the accounts it has locally... but I can't find
> anything that helps.
>
> Thanks experts!
Here you go:

const cdoBasic=1
schema = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "James@xxxxxx"
.To = "Jim@xxxxxx"
.Subject = "Test Mail"
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
.AddAttachment "d:\Testfile.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.company.com"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = "James@xxxxxx"
.Item (schema & "smtpaccountname") = "James@xxxxxx"
.Item (schema & "sendpassword") = "SomePassword"
End With
.Configuration.Fields.Update
.Send
End With


My System SpecsSystem Spec
Old 08-13-2009   #3 (permalink)
Robert Jacobs


 
 

Re: Send E-Mail

On Aug 12, 12:21*pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

> "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
> news:4c48a6bf-4c31-4e20-a720-f5b8df101752@xxxxxx
>
>
>
>
>
Quote:

> > Thanks in advance for your help!
>
Quote:

> > I have a VB script that I would like to send e-mails to internal e-
> > mail addresses when an error occurs. *I have the error checking setup,
> > and currently it logs to a file - however, I would like to get it to
> > send an e-mail to our helpdesk when an error is encountered. *The
> > message would never need to leave our network.
>
Quote:

> > We have an SMTP server on the same subnet as well. *Does anybody know
> > how I can send a basic e-mail from the script? *I can use 3rd party
> > software, if required, but would like that to be a last resort.
>
Quote:

> > It seems simple - contact the SMTP server and tell it to send a
> > message to one of the accounts it has locally... but I can't find
> > anything that helps.
>
Quote:

> > Thanks experts!
>
> Here you go:
>
> const cdoBasic=1
> schema = "http://schemas.microsoft.com/cdo/configuration/"
> Set objEmail = CreateObject("CDO.Message")
> With objEmail
> *.From = "Ja...@xxxxxx"
> *.To = "J...@xxxxxx"
> *.Subject = "Test Mail"
> *.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
> *.AddAttachment "d:\Testfile.txt"
> *With .Configuration.Fields
> * .Item (schema & "sendusing") = 2
> * .Item (schema & "smtpserver") = "mail.company.com"
> * .Item (schema & "smtpserverport") = 25
> * .Item (schema & "smtpauthenticate") = cdoBasic
> * .Item (schema & "sendusername") = "Ja...@xxxxxx"
> * .Item (schema & "smtpaccountname") = "Ja...@xxxxxx"
> * .Item (schema & "sendpassword") = "SomePassword"
> *End With
> *.Configuration.Fields.Update
> *.Send
> End With- Hide quoted text -
>
> - Show quoted text -
Thanks Pegasus. Is there a way to do this without using Microsoft's
website? For instance, if our internet connection goes down, this
wouldn't work, correct? If not built into VBScript, is there a
program that can be installed, and called by the VBScript when
needed? Just something other than requiring an internet connection to
function properly would be great.
My System SpecsSystem Spec
Old 08-13-2009   #4 (permalink)
Pegasus [MVP]


 
 

Re: Send E-Mail


"Robert Jacobs" <robertjacobsit@xxxxxx> wrote in message
news:ff5e93fa-7bbc-44be-83b9-114e61c02ead@xxxxxx
On Aug 12, 12:21 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

> "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
> news:4c48a6bf-4c31-4e20-a720-f5b8df101752@xxxxxx
>
>
>
>
>
Quote:

> > Thanks in advance for your help!
>
Quote:

> > I have a VB script that I would like to send e-mails to internal e-
> > mail addresses when an error occurs. I have the error checking setup,
> > and currently it logs to a file - however, I would like to get it to
> > send an e-mail to our helpdesk when an error is encountered. The
> > message would never need to leave our network.
>
Quote:

> > We have an SMTP server on the same subnet as well. Does anybody know
> > how I can send a basic e-mail from the script? I can use 3rd party
> > software, if required, but would like that to be a last resort.
>
Quote:

> > It seems simple - contact the SMTP server and tell it to send a
> > message to one of the accounts it has locally... but I can't find
> > anything that helps.
>
Quote:

> > Thanks experts!
>
> Here you go:
>
> const cdoBasic=1
> schema = "http://schemas.microsoft.com/cdo/configuration/"
> Set objEmail = CreateObject("CDO.Message")
> With objEmail
> .From = "Ja...@xxxxxx"
> .To = "J...@xxxxxx"
> .Subject = "Test Mail"
> .Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
> .AddAttachment "d:\Testfile.txt"
> With .Configuration.Fields
> .Item (schema & "sendusing") = 2
> .Item (schema & "smtpserver") = "mail.company.com"
> .Item (schema & "smtpserverport") = 25
> .Item (schema & "smtpauthenticate") = cdoBasic
> .Item (schema & "sendusername") = "Ja...@xxxxxx"
> .Item (schema & "smtpaccountname") = "Ja...@xxxxxx"
> .Item (schema & "sendpassword") = "SomePassword"
> End With
> .Configuration.Fields.Update
> .Send
> End With- Hide quoted text -
>
> - Show quoted text -
Thanks Pegasus. Is there a way to do this without using Microsoft's
website? For instance, if our internet connection goes down, this
wouldn't work, correct? If not built into VBScript, is there a
program that can be installed, and called by the VBScript when
needed? Just something other than requiring an internet connection to
function properly would be great.

=============

I don't know if this function depends on you having a live Internet
connection. If you want to be sure then you can use blat.exe. It is
downloadable from a number of web sites.


My System SpecsSystem Spec
Old 08-13-2009   #5 (permalink)
Robert Jacobs


 
 

Re: Send E-Mail

On Aug 13, 3:09*pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

> "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
> news:ff5e93fa-7bbc-44be-83b9-114e61c02ead@xxxxxx
> On Aug 12, 12:21 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
Quote:

> >news:4c48a6bf-4c31-4e20-a720-f5b8df101752@xxxxxx
>
Quote:
Quote:

> > > Thanks in advance for your help!
>
Quote:
Quote:

> > > I have a VB script that I would like to send e-mails to internal e-
> > > mail addresses when an error occurs. I have the error checking setup,
> > > and currently it logs to a file - however, I would like to get it to
> > > send an e-mail to our helpdesk when an error is encountered. The
> > > message would never need to leave our network.
>
Quote:
Quote:

> > > We have an SMTP server on the same subnet as well. Does anybody know
> > > how I can send a basic e-mail from the script? I can use 3rd party
> > > software, if required, but would like that to be a last resort.
>
Quote:
Quote:

> > > It seems simple - contact the SMTP server and tell it to send a
> > > message to one of the accounts it has locally... but I can't find
> > > anything that helps.
>
Quote:
Quote:

> > > Thanks experts!
>
Quote:

> > Here you go:
>
Quote:

> > const cdoBasic=1
> > schema = "http://schemas.microsoft.com/cdo/configuration/"
> > Set objEmail = CreateObject("CDO.Message")
> > With objEmail
> > .From = "Ja...@xxxxxx"
> > .To = "J...@xxxxxx"
> > .Subject = "Test Mail"
> > .Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
> > .AddAttachment "d:\Testfile.txt"
> > With .Configuration.Fields
> > .Item (schema & "sendusing") = 2
> > .Item (schema & "smtpserver") = "mail.company.com"
> > .Item (schema & "smtpserverport") = 25
> > .Item (schema & "smtpauthenticate") = cdoBasic
> > .Item (schema & "sendusername") = "Ja...@xxxxxx"
> > .Item (schema & "smtpaccountname") = "Ja...@xxxxxx"
> > .Item (schema & "sendpassword") = "SomePassword"
> > End With
> > .Configuration.Fields.Update
> > .Send
> > End With- Hide quoted text -
>
Quote:

> > - Show quoted text -
>
> Thanks Pegasus. *Is there a way to do this without using Microsoft's
> website? *For instance, if our internet connection goes down, this
> wouldn't work, correct? *If not built into VBScript, is there a
> program that can be installed, and called by the VBScript when
> needed? *Just something other than requiring an internet connection to
> function properly would be great.
>
> =============
>
> I don't know if this function depends on you having a live Internet
> connection. If you want to be sure then you can use blat.exe. It is
> downloadable from a number of web sites.- Hide quoted text -
>
> - Show quoted text -
Great, thanks. I just assumed it required internet because of the
line:

schema = "http://schemas.microsoft.com/cdo/configuration/"

Am I incorrect in that statement? Otherwise, it works perfectly!
Please let me know... If not, I will check out blat. thanks again!
My System SpecsSystem Spec
Old 08-13-2009   #6 (permalink)
Pegasus [MVP]


 
 

Re: Send E-Mail


"Robert Jacobs" <robertjacobsit@xxxxxx> wrote in message
news:2210804d-51ad-47b3-a5e7-b53133736a23@xxxxxx
On Aug 13, 3:09 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

> "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
> news:ff5e93fa-7bbc-44be-83b9-114e61c02ead@xxxxxx
> On Aug 12, 12:21 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
Quote:

> >news:4c48a6bf-4c31-4e20-a720-f5b8df101752@xxxxxx
>
Quote:
Quote:

> > > Thanks in advance for your help!
>
Quote:
Quote:

> > > I have a VB script that I would like to send e-mails to internal e-
> > > mail addresses when an error occurs. I have the error checking setup,
> > > and currently it logs to a file - however, I would like to get it to
> > > send an e-mail to our helpdesk when an error is encountered. The
> > > message would never need to leave our network.
>
Quote:
Quote:

> > > We have an SMTP server on the same subnet as well. Does anybody know
> > > how I can send a basic e-mail from the script? I can use 3rd party
> > > software, if required, but would like that to be a last resort.
>
Quote:
Quote:

> > > It seems simple - contact the SMTP server and tell it to send a
> > > message to one of the accounts it has locally... but I can't find
> > > anything that helps.
>
Quote:
Quote:

> > > Thanks experts!
>
Quote:

> > Here you go:
>
Quote:

> > const cdoBasic=1
> > schema = "http://schemas.microsoft.com/cdo/configuration/"
> > Set objEmail = CreateObject("CDO.Message")
> > With objEmail
> > .From = "Ja...@xxxxxx"
> > .To = "J...@xxxxxx"
> > .Subject = "Test Mail"
> > .Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
> > .AddAttachment "d:\Testfile.txt"
> > With .Configuration.Fields
> > .Item (schema & "sendusing") = 2
> > .Item (schema & "smtpserver") = "mail.company.com"
> > .Item (schema & "smtpserverport") = 25
> > .Item (schema & "smtpauthenticate") = cdoBasic
> > .Item (schema & "sendusername") = "Ja...@xxxxxx"
> > .Item (schema & "smtpaccountname") = "Ja...@xxxxxx"
> > .Item (schema & "sendpassword") = "SomePassword"
> > End With
> > .Configuration.Fields.Update
> > .Send
> > End With- Hide quoted text -
>
Quote:

> > - Show quoted text -
>
> Thanks Pegasus. Is there a way to do this without using Microsoft's
> website? For instance, if our internet connection goes down, this
> wouldn't work, correct? If not built into VBScript, is there a
> program that can be installed, and called by the VBScript when
> needed? Just something other than requiring an internet connection to
> function properly would be great.
>
> =============
>
> I don't know if this function depends on you having a live Internet
> connection. If you want to be sure then you can use blat.exe. It is
> downloadable from a number of web sites.- Hide quoted text -
>
> - Show quoted text -
Great, thanks. I just assumed it required internet because of the
line:

schema = "http://schemas.microsoft.com/cdo/configuration/"

Am I incorrect in that statement? Otherwise, it works perfectly!
Please let me know... If not, I will check out blat. thanks again!

==================

I am not near an in-house SMTP server right now, so you'll have to check it
out yourself.


My System SpecsSystem Spec
Old 08-13-2009   #7 (permalink)
Robert Jacobs


 
 

Re: Send E-Mail

On Aug 13, 3:51*pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
Quote:

> "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
> news:2210804d-51ad-47b3-a5e7-b53133736a23@xxxxxx
> On Aug 13, 3:09 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
Quote:

> >news:ff5e93fa-7bbc-44be-83b9-114e61c02ead@xxxxxx
> > On Aug 12, 12:21 pm, "Pegasus [MVP]" <n...@xxxxxx> wrote:
>
Quote:
Quote:

> > > "Robert Jacobs" <robertjacob...@xxxxxx> wrote in message
>
Quote:
Quote:

> > >news:4c48a6bf-4c31-4e20-a720-f5b8df101752@xxxxxx
>
Quote:
Quote:

> > > > Thanks in advance for your help!
>
Quote:
Quote:

> > > > I have a VB script that I would like to send e-mails to internal e-
> > > > mail addresses when an error occurs. I have the error checking setup,
> > > > and currently it logs to a file - however, I would like to get it to
> > > > send an e-mail to our helpdesk when an error is encountered. The
> > > > message would never need to leave our network.
>
Quote:
Quote:

> > > > We have an SMTP server on the same subnet as well. Does anybody know
> > > > how I can send a basic e-mail from the script? I can use 3rd party
> > > > software, if required, but would like that to be a last resort.
>
Quote:
Quote:

> > > > It seems simple - contact the SMTP server and tell it to send a
> > > > message to one of the accounts it has locally... but I can't find
> > > > anything that helps.
>
Quote:
Quote:

> > > > Thanks experts!
>
Quote:
Quote:

> > > Here you go:
>
Quote:
Quote:

> > > const cdoBasic=1
> > > schema = "http://schemas.microsoft.com/cdo/configuration/"
> > > Set objEmail = CreateObject("CDO.Message")
> > > With objEmail
> > > .From = "Ja...@xxxxxx"
> > > .To = "J...@xxxxxx"
> > > .Subject = "Test Mail"
> > > .Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazydog"
> > > .AddAttachment "d:\Testfile.txt"
> > > With .Configuration.Fields
> > > .Item (schema & "sendusing") = 2
> > > .Item (schema & "smtpserver") = "mail.company.com"
> > > .Item (schema & "smtpserverport") = 25
> > > .Item (schema & "smtpauthenticate") = cdoBasic
> > > .Item (schema & "sendusername") = "Ja...@xxxxxx"
> > > .Item (schema & "smtpaccountname") = "Ja...@xxxxxx"
> > > .Item (schema & "sendpassword") = "SomePassword"
> > > End With
> > > .Configuration.Fields.Update
> > > .Send
> > > End With- Hide quoted text -
>
Quote:
Quote:

> > > - Show quoted text -
>
Quote:

> > Thanks Pegasus. Is there a way to do this without using Microsoft's
> > website? For instance, if our internet connection goes down, this
> > wouldn't work, correct? If not built into VBScript, is there a
> > program that can be installed, and called by the VBScript when
> > needed? Just something other than requiring an internet connection to
> > function properly would be great.
>
Quote:

> > =============
>
Quote:

> > I don't know if this function depends on you having a live Internet
> > connection. If you want to be sure then you can use blat.exe. It is
> > downloadable from a number of web sites.- Hide quoted text -
>
Quote:

> > - Show quoted text -
>
> Great, thanks. *I just assumed it required internet because of the
> line:
>
> schema = "http://schemas.microsoft.com/cdo/configuration/"
>
> Am I incorrect in that statement? *Otherwise, it works perfectly!
> Please let me know... If not, I will check out blat. *thanks again!
>
> ==================
>
> I am not near an in-house SMTP server right now, so you'll have to check it
> out yourself.- Hide quoted text -
>
> - Show quoted text -
Thanks - The only way for me to test it is to disconnect the internet,
and doing so would disconnect it for the entire company. I'll just
have to assume it doesn't work, and use blat, thanks again.
My System SpecsSystem Spec
Old 08-13-2009   #8 (permalink)
mayayana


 
 

Re: Send E-Mail

Thanks - The only way for me to test it is to disconnect the internet,
and doing so would disconnect it for the entire company. I'll just
have to assume it doesn't work, and use blat, thanks again.
--------------

I've always wondered about that, too, though I've
never needed CDO so I never looked into it. It seems
very odd that a URL should be needed to name a
property. And the actual URL doesn't seem to be
a valid one. I've been waiting to hear the explanation
in this thread but apparently neither Pegasus nor anyone
else knows why it works that way either. I wonder if you
could just leave out that line?


My System SpecsSystem Spec
Old 08-14-2009   #9 (permalink)
Robert Jacobs


 
 

Re: Send E-Mail

On Aug 13, 4:50*pm, "mayayana" <mayaXXy...@xxxxxx> wrote:
Quote:

> Thanks - The only way for me to test it is to disconnect the internet,
> and doing so would disconnect it for the entire company. *I'll just
> have to assume it doesn't work, and use blat, thanks again.
> --------------
>
> * I've always wondered about that, too, though I've
> never needed CDO so I never looked into it. It seems
> very odd that a URL should be needed to name a
> property. And the actual URL doesn't seem to be
> a valid one. I've been waiting to hear the explanation
> in this thread but apparently neither Pegasus nor anyone
> else knows why it works that way either. I wonder if you
> could just leave out that line?
I know you can't just leave that line out, because schema is called
again multiple times. I'm working on figuring out how to maintain a
connection to our SMTP server while not having access to the internet,
harder than I thought... I'll let you know when I get it figured out.
My System SpecsSystem Spec
Old 08-14-2009   #10 (permalink)
Robert Jacobs


 
 

Re: Send E-Mail

On Aug 13, 4:50*pm, "mayayana" <mayaXXy...@xxxxxx> wrote:
Quote:

> Thanks - The only way for me to test it is to disconnect the internet,
> and doing so would disconnect it for the entire company. *I'll just
> have to assume it doesn't work, and use blat, thanks again.
> --------------
>
> * I've always wondered about that, too, though I've
> never needed CDO so I never looked into it. It seems
> very odd that a URL should be needed to name a
> property. And the actual URL doesn't seem to be
> a valid one. I've been waiting to hear the explanation
> in this thread but apparently neither Pegasus nor anyone
> else knows why it works that way either. I wonder if you
> could just leave out that line?
Good news, I changed the default gateway (actually, just removed it)
on the server, and this allowed me to still access all the servers/
desktops on my network my IP address or name, but not access anything
on the internet. I ran the script - and... woohoo! Everything still
works!!!

Thanks Pegasus!
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Right Click Send To Mail recipient - Send button doesnt work Vista General
can you tell me why i cant send mail and why my new microsoft cant send what i typed to my email Vista mail
Windows-Mail - invitation not send by mail - meeting not send by mail Vista mail
Windows mail can't send email but in XP/2000 pro. send working OK Vista mail
Cannot Send Mail (task window not even showing send mail) Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46