Post Content

This is just a function snippet, sends an email with attachments, must manually edit function with email and attachment parameters.

Used in EmailLogs.vbs and ProcessManager.vbs

Script[-][--][++]

Sub SendLogEmail()
    Set pc = CreateObject("Wscript.Network")
    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")
    Set Flds = iConf.Fields

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

    Flds.Item(schema & "sendusing") = 2
    Flds.Item(schema & "smtpserver") = "xxx.xxx.xxx.xxx" 
    Flds.Item(schema & "smtpserverport") = 25
    Flds.Item(schema & "smtpauthenticate") = 0
    'Flds.Item(schema & "sendusername") = "domain\user"
    'Flds.Item(schema & "sendpassword") = ""
    Flds.Item(schema & "smtpusessl") = 0
    Flds.Update

    With iMsg
        .To = "you@mail.com,you2@mail.com"
        .From = "FromName "

        .Subject = pc.ComputerName & " log"
        .AddAttachment(logFile)
        .HTMLBody = "SomeBody for email here, server: " & pc.ComputerName & ""
        
        .Sender = "FromName "
        .Organization = "Your Company"
        .ReplyTo = "replyhere@mail.com"

        Set .Configuration = iConf

        .Send 
    End With   
  
    ' Release Interfaces
    Set iMsg = nothing
    Set iConf = nothing
    Set Flds = nothing
End Sub

Resources[-][--][++]

http://www.paulsadowski.com/WSH/cdo.htm


Keywords

vbs vbscript visual basic script scripts email snippets ms microsoft studio .net shell scripting