"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
>
>
>
>
>>
> > 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. >>
> 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?