Windows Vista Forums

Unable to send Mail Using vbscript
  1. #1


    Mark Guest

    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

  2. #2


    Pegasus \(MVP\) Guest

    Re: Unable to send Mail Using vbscript


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

    > 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

  3. #3


    OldDog Guest

    Re: Unable to send Mail Using vbscript

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

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

    > > 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 = "sam...@xxxxxx"
    > > * *objMessage.To = "sam...@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 valueis
    > > 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 = "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 -----------------------------------

    >
    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

  4. #4


    Pegasus \(MVP\) Guest

    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:

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

    > > 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 = "sam...@xxxxxx"
    > > objMessage.To = "sam...@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 = "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 -----------------------------------

    >
    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

  5. #5


    David Guest

    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

    > 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

  6. #6


    Mark Guest

    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:

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

    > > 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

  7. #7


    Pegasus \(MVP\) Guest

    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

    > 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:
    >

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

    >> > 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

Unable to send Mail Using vbscript problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to send e-mail and get error message when opening live mail biggwg Live Mail 1 13 Jan 2010
Unable to send or recieve mail with Windows Live Mail Chris Live Mail 2 11 Jan 2010
Unable to send mail Kathy Vista mail 1 09 Dec 2008
Unable to send mail JP Vista mail 1 12 Jul 2008
Unable to send Mail Courtney Vista mail 4 05 Nov 2007