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 - Unable to send Mail Using vbscript

Reply
 
Old 11-12-2008   #1 (permalink)
Mark


 
 

Unable to send Mail Using vbscript

Hi

I have modified a script to send a mail with a file attachment. Please find
the script bellow.

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Free Disk Space Report"
objMessage.Sender = "sample@xxxxxx"
objMessage.To = "sample@xxxxxx"
objMessage.AddAttachment ("C:\Diskspace_"& testdate &".log")
objMessage.Send
Set objMessage = nothing

The above script works perfectly in a workgroup If I try to execute the same
script in domain. Its giving a error as
"C:\Sample.vbs(7, 5) CDO.Message.1: The "SendUsing" configuration value is
invalid"

Can any one please give some tips to avoid this error.

Thanks

My System SpecsSystem Spec
Old 11-13-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Unable to send Mail Using vbscript


"Mark" <Mark@xxxxxx> wrote in message
news:06B7187B-E589-443C-B2C4-29E2A7165EE2@xxxxxx
Quote:

> Hi
>
> I have modified a script to send a mail with a file attachment. Please
> find
> the script bellow.
>
> Set objMessage = CreateObject("CDO.Message")
> objMessage.Subject = "Free Disk Space Report"
> objMessage.Sender = "sample@xxxxxx"
> objMessage.To = "sample@xxxxxx"
> objMessage.AddAttachment ("C:\Diskspace_"& testdate &".log")
> objMessage.Send
> Set objMessage = nothing
>
> The above script works perfectly in a workgroup If I try to execute the
> same
> script in domain. Its giving a error as
> "C:\Sample.vbs(7, 5) CDO.Message.1: The "SendUsing" configuration value is
> invalid"
>
> Can any one please give some tips to avoid this error.
>
> Thanks
It seems there are a few settings missing from your script, e.g. your SMTP
server. Try this version:

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 & "sendpassword") = "SomePassword"
End With
.Configuration.Fields.Update
.Send
End With


My System SpecsSystem Spec
Old 11-14-2008   #3 (permalink)
OldDog


 
 

Re: Unable to send Mail Using vbscript

On Nov 13, 1:02*am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Mark" <M...@xxxxxx> wrote in message
>
> news:06B7187B-E589-443C-B2C4-29E2A7165EE2@xxxxxx
>
>
>
>
>
Quote:

> > Hi
>
Quote:

> > I have modified a script to send a mail with a file attachment. Please
> > find
> > the script bellow.
>
Quote:

> > Set objMessage = CreateObject("CDO.Message")
> > * *objMessage.Subject = "Free Disk Space Report"
> > * *objMessage.Sender = "sam...@xxxxxx"
> > * *objMessage.To = "sam...@xxxxxx"
> > * *objMessage.AddAttachment ("C:\Diskspace_"& testdate &".log")
> > * *objMessage.Send
> > Set objMessage = nothing
>
Quote:

> > The above script works perfectly in a workgroup If I try to execute the
> > same
> > script in domain. Its giving a error as
> > "C:\Sample.vbs(7, 5) CDO.Message.1: The "SendUsing" configuration valueis
> > invalid"
>
Quote:

> > Can any one please give some tips to avoid this error.
>
Quote:

> > Thanks
>
> It seems there are a few settings missing from your script, e.g. your SMTP
> server. Try this version:
>
> 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 & "sendpassword") = "SomePassword"
> *End With
> *.Configuration.Fields.Update
> *.Send
> End With- Hide quoted text -
>
> - Show quoted text -
Or this;

'<------------Begin----------------------------------------------->

adminmail = "somebody@xxxxxx"
'
smtp = "mail_server name or IP"
Set mailing = CreateObject("CDO.Message")
Set wshNet = CreateObject("WScript.Network")

mailing.From = ("fromSomeone@xxxxxx")
mailing.To = adminmail
mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/sendusing") = 2
mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/smtpserver") = smtp
mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/smtpserverport") = 25
mailing.Subject = header & "Data Transfer Success logs"
sFullProductionMessage = "See attached file..." & vbcrlf
mailing.TextBody = sFullProductionMessage
mailing.Configuration.Fields.Update
mailing.AddAttachment "R:\dailylog.txt"
mailing.Send
On Error Goto 0

'<---------------------------- END -----------------------------------
Quote:

>
What if you wanted the Attachment to be the body text?

Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the file for reading
Set f = fso.OpenTextFile("C:\SendLogs\dailylog.txt", ForReading)
'The ReadAll method reads the entire file into the variable BodyText
BodyText = f.ReadAll
'Close the file
f.Close
Set f = Nothing
Set fso = Nothing

And in your message function or sub or whatever;

mailing.TextBody = BodyText

How about CC?

mailing.Cc = "someoneelse@xxxxxx"

OldDog
My System SpecsSystem Spec
Old 11-14-2008   #4 (permalink)
Pegasus \(MVP\)


 
 

Re: Unable to send Mail Using vbscript


"OldDog" <mikef2691@xxxxxx> wrote in message
news:14c820ff-e2c7-4678-9496-94ebeaded113@xxxxxx
On Nov 13, 1:02 am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Mark" <M...@xxxxxx> wrote in message
>
> news:06B7187B-E589-443C-B2C4-29E2A7165EE2@xxxxxx
>
>
>
>
>
Quote:

> > Hi
>
Quote:

> > I have modified a script to send a mail with a file attachment. Please
> > find
> > the script bellow.
>
Quote:

> > Set objMessage = CreateObject("CDO.Message")
> > objMessage.Subject = "Free Disk Space Report"
> > objMessage.Sender = "sam...@xxxxxx"
> > objMessage.To = "sam...@xxxxxx"
> > objMessage.AddAttachment ("C:\Diskspace_"& testdate &".log")
> > objMessage.Send
> > Set objMessage = nothing
>
Quote:

> > The above script works perfectly in a workgroup If I try to execute the
> > same
> > script in domain. Its giving a error as
> > "C:\Sample.vbs(7, 5) CDO.Message.1: The "SendUsing" configuration value
> > is
> > invalid"
>
Quote:

> > Can any one please give some tips to avoid this error.
>
Quote:

> > Thanks
>
> It seems there are a few settings missing from your script, e.g. your SMTP
> server. Try this version:
>
> 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 & "sendpassword") = "SomePassword"
> End With
> .Configuration.Fields.Update
> .Send
> End With- Hide quoted text -
>
> - Show quoted text -
Or this;

'<------------Begin----------------------------------------------->

adminmail = "somebody@xxxxxx"
'
smtp = "mail_server name or IP"
Set mailing = CreateObject("CDO.Message")
Set wshNet = CreateObject("WScript.Network")

mailing.From = ("fromSomeone@xxxxxx")
mailing.To = adminmail
mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/sendusing") = 2
mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/smtpserver") = smtp
mailing.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/
configuration/smtpserverport") = 25
mailing.Subject = header & "Data Transfer Success logs"
sFullProductionMessage = "See attached file..." & vbcrlf
mailing.TextBody = sFullProductionMessage
mailing.Configuration.Fields.Update
mailing.AddAttachment "R:\dailylog.txt"
mailing.Send
On Error Goto 0

'<---------------------------- END -----------------------------------
Quote:

>
What if you wanted the Attachment to be the body text?

Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the file for reading
Set f = fso.OpenTextFile("C:\SendLogs\dailylog.txt", ForReading)
'The ReadAll method reads the entire file into the variable BodyText
BodyText = f.ReadAll
'Close the file
f.Close
Set f = Nothing
Set fso = Nothing

And in your message function or sub or whatever;

mailing.TextBody = BodyText

How about CC?

mailing.Cc = "someoneelse@xxxxxx"

OldDog

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

You're replying to me - are you asking me a question?


My System SpecsSystem Spec
Old 11-14-2008   #5 (permalink)
David


 
 

Re: Unable to send Mail Using vbscript

easy in VBS:

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objEmail = CreateObject("CDO.Message")

objEmail.From = "user@xxxxxx"
objEmail.To = "user@xxxxxx"
objEmail.Subject = "Subject Line"
objEmail.Textbody = ""
objEmail.AddAttachment "c:\folder\filename.extension"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"exchangeservername"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send


"Mark" <Mark@xxxxxx> wrote in message
news:06B7187B-E589-443C-B2C4-29E2A7165EE2@xxxxxx
Quote:

> Hi
>
> I have modified a script to send a mail with a file attachment. Please
> find
> the script bellow.
>
> Set objMessage = CreateObject("CDO.Message")
> objMessage.Subject = "Free Disk Space Report"
> objMessage.Sender = "sample@xxxxxx"
> objMessage.To = "sample@xxxxxx"
> objMessage.AddAttachment ("C:\Diskspace_"& testdate &".log")
> objMessage.Send
> Set objMessage = nothing
>
> The above script works perfectly in a workgroup If I try to execute the
> same
> script in domain. Its giving a error as
> "C:\Sample.vbs(7, 5) CDO.Message.1: The "SendUsing" configuration value is
> invalid"
>
> Can any one please give some tips to avoid this error.
>
> Thanks
My System SpecsSystem Spec
Old 11-17-2008   #6 (permalink)
Mark


 
 

Re: Unable to send Mail Using vbscript

Hi Thanks Its works fine
But I am using a pop3 mail account type. When I put cc to my gmail account I
am get any mail in gmail. But the mail reach to the addressed person on TO.

Can you explane me how to sort out this problem.


"Pegasus (MVP)" wrote:
Quote:

>
> "Mark" <Mark@xxxxxx> wrote in message
> news:06B7187B-E589-443C-B2C4-29E2A7165EE2@xxxxxx
Quote:

> > Hi
> >
> > I have modified a script to send a mail with a file attachment. Please
> > find
> > the script bellow.
> >
> > Set objMessage = CreateObject("CDO.Message")
> > objMessage.Subject = "Free Disk Space Report"
> > objMessage.Sender = "sample@xxxxxx"
> > objMessage.To = "sample@xxxxxx"
> > objMessage.AddAttachment ("C:\Diskspace_"& testdate &".log")
> > objMessage.Send
> > Set objMessage = nothing
> >
> > The above script works perfectly in a workgroup If I try to execute the
> > same
> > script in domain. Its giving a error as
> > "C:\Sample.vbs(7, 5) CDO.Message.1: The "SendUsing" configuration value is
> > invalid"
> >
> > Can any one please give some tips to avoid this error.
> >
> > Thanks
>
> It seems there are a few settings missing from your script, e.g. your SMTP
> server. Try this version:
>
> 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 & "sendpassword") = "SomePassword"
> End With
> .Configuration.Fields.Update
> .Send
> End With
>
>
>
My System SpecsSystem Spec
Old 11-17-2008   #7 (permalink)
Pegasus \(MVP\)


 
 

Re: Unable to send Mail Using vbscript

Let's have a look at your current script.

"Mark" <Mark@xxxxxx> wrote in message
news:77655070-89F6-4E5F-A538-DD31391EFC0A@xxxxxx
Quote:

> Hi Thanks Its works fine
> But I am using a pop3 mail account type. When I put cc to my gmail account
> I
> am get any mail in gmail. But the mail reach to the addressed person on
> TO.
>
> Can you explane me how to sort out this problem.
>
>
> "Pegasus (MVP)" wrote:
>
Quote:

>>
>> "Mark" <Mark@xxxxxx> wrote in message
>> news:06B7187B-E589-443C-B2C4-29E2A7165EE2@xxxxxx
Quote:

>> > Hi
>> >
>> > I have modified a script to send a mail with a file attachment. Please
>> > find
>> > the script bellow.
>> >
>> > Set objMessage = CreateObject("CDO.Message")
>> > objMessage.Subject = "Free Disk Space Report"
>> > objMessage.Sender = "sample@xxxxxx"
>> > objMessage.To = "sample@xxxxxx"
>> > objMessage.AddAttachment ("C:\Diskspace_"& testdate &".log")
>> > objMessage.Send
>> > Set objMessage = nothing
>> >
>> > The above script works perfectly in a workgroup If I try to execute the
>> > same
>> > script in domain. Its giving a error as
>> > "C:\Sample.vbs(7, 5) CDO.Message.1: The "SendUsing" configuration value
>> > is
>> > invalid"
>> >
>> > Can any one please give some tips to avoid this error.
>> >
>> > Thanks
>>
>> It seems there are a few settings missing from your script, e.g. your
>> SMTP
>> server. Try this version:
>>
>> 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 & "sendpassword") = "SomePassword"
>> End With
>> .Configuration.Fields.Update
>> .Send
>> End With
>>
>>
>>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Unable to send mail Vista mail
Unable to send mail Vista mail
Unable to send e-mail Vista mail
I am unable to send e-mail Vista mail
unable to 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