VBS - subSendEMail 

sub subSendEMail(tfrom, tto, tsubject, tbody)
   
        'on error resume next
       
        Set objMessage = CreateObject("CDO.Message")
        objMessage.Subject = tsubject
        objMessage.From = tfrom
        objMessage.To = tto
        objMessage.CC = "chadchase@crouse.org"
         objMessage.BCC = "richlemmermann@crouse.org"
        'objMessage.BCC = ""
        objMessage.TextBody = tbody
       
       
        '==This section provides the configuration information for the remote SMTP server.
        '==Normally you will only change the server name or IP.
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
       
        'Name or IP of Remote SMTP Server
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailserver"
       
        'Server port (typically 25)
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25


       
        objMessage.Configuration.Fields.Update
       
        wscript.stdout.write "Sending to: " & tto & vbtab
        objMessage.Send
        wscript.echo err.description
       
        set objMessage = nothing
   
        on error goto 0
   
 end sub 

PowerShell - Turn Off Monitor

# Make monitor turn off/sleep
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "(Add-Type '[DllImport(\"user32.dll\")]public static extern int SendMessage(int hWnd,int hMsg,int wParam,int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)"

PowerShell FTP and Send-ToEmail

##

# Program: ftp_upload.ps1

# Purpose: Take orders of a specified file type and ftp them to a server location. Archive

#          them afterwards and send an email with the filesnames of the files uploaded

# Date: 08/2018

##

# source directory to search for files

$source_directory = "C:\Users\nburchfield\Desktop\temp\"

# archive location after upload

$archive_directory = "C:\Users\nburchfield\Desktop\temp\Archive\"

# extensions to search for upload

$extension = "*.txt"

# once uploaded, the source file paths are kept here

$uploaded_files = @();

##

## ftp connection information

##

$ftp_host = "10.2.2.10"

$ftp_uname = "REDACTED";

$ftp_pass = "REDACTED";

##

## smtp mail variables

##

$smtp_host = "apollo.johnstonpaper.com"

$smtp_port = "25"

$msg_from = "xmlorders@johnston.biz"

$msg_sub = "JMART - XML Orders Uploaded"

$msg_to = "helpdesk@johnston.biz,nathan.burchfield@johnston.biz"

$msg_body = "The following files were uploaded to $($ftp_host):`n`n"

#$smtp_user = "MyUserName";

#$smtp_pass = "MyPassword";

#$attach_path = "C:\attachment.txt"; # optional

## this function will send an email using the following parameters. (attachment is optional:

function Send-ToEmail([string]$destination, [string]$from, [string]$subject, [string]$body, [string]$attachmentpath){

   

    $message = new-object Net.Mail.MailMessage;

    $message.From = $from;

    $message.To.Add($destination);

    $message.Subject = $subject;

    $message.Body = $body;

    ## only if attachment exists (optional):

    if ($attachmentpath -ne $null -and $attachmentpath -ne "") {

        Write-Host "Attaching file: " $attachmentpath

        $attachment = New-Object Net.Mail.Attachment($attachmentpath);

        $message.Attachments.Add($attachment);

    }

    $smtp = new-object Net.Mail.SmtpClient($smtp_host, $smtp_port);

    $smtp.EnableSSL = $true;

    #$smtp.Credentials = New-Object System.Net.NetworkCredential($smtp_user, $smtp_pass);

    $smtp.send($message);

    if ($attachment -ne $null) { $attachment.Dispose(); }

    if ($message -ne $null) { $message.Dispose(); }

}

# pass it a src and dest, and it will upload based on the variables above

function Ftp-Upload([string]$src, [string]$dest) {

   

    # create the FtpWebRequest and configure it

    $ftp = [System.Net.FtpWebRequest]::Create("ftp://$ftp_host/$dest")

    $ftp = [System.Net.FtpWebRequest]$ftp

    $ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile

    $ftp.Credentials = new-object System.Net.NetworkCredential($ftp_uname, $ftp_pass)

    $ftp.UseBinary = $true

    $ftp.UsePassive = $true

   

    # read in the file to a byte array

    $content = [System.IO.File]::ReadAllBytes($src)

    $ftp.ContentLength = $content.Length

    # write the bytes to the request stream

    $rs = $ftp.GetRequestStream()

    $rs.Write($content, 0, $content.Length)

    # cleanup

    if ($rs -ne $null) { $rs.Close(); $rs.Dispose(); }

}

# based on the variables above, read in all files and upload them

Get-ChildItem $source_directory -Filter $extension | Foreach-Object {

    $f_source = $_.FullName

    $f_destination = $_.Name

    # run the upload

    Ftp-Upload -src $f_source -dest $f_destination

    # append to the list for archive:

    $uploaded_files += $f_source

}

# if files were uploaded...

if ($uploaded_files.count -gt 0) {

    # for each file we uploaded, archive it and remove it

    foreach ($file in $uploaded_files) {

   

        # get the base filename

        $filename = Split-Path -Path $file -Leaf -Resolve

        # copy the file to archive location and delete it

        Copy-Item $file -Destination "$archive_directory$filename"

        Remove-Item $file

        $msg_body += "[>] $filename uploaded and archived.`n"

    }

    # log to console and send via email

    Write-Host $msg_body

    Send-ToEmail  -destination $msg_to -from $msg_from -subject $msg_sub -body $msg_body;

} else {

    # no files found - keep moving

    Write-Host "[#] No Files Uploaded."

}

$date_finished = (Get-Date -Format g) | Out-String

$date_finished = $date_finished -replace "`t|`n|`r",""

Write-Host "`n`n[>] Finished! ($date_finished)"

Provided by Nate Burchfield

VB.NET - Send Email

Imports System.Net.Mail

function funSendMail(txtFrom as string, txtTo as string, txtSubject as string, txtMessage as string, bIsHTML as boolean) as boolean

      Try

         Dim Smtp_Server As New SmtpClient

         Dim e_mail As New MailMessage()

        

         ' ********************* Customize for environment

         Smtp_Server.UseDefaultCredentials = False

         Smtp_Server.Credentials = New Net.NetworkCredential("username@gmail.com", "password")

         Smtp_Server.Port = 587

         Smtp_Server.EnableSsl = True

         Smtp_Server.Host = "smtp.gmail.com"

         ' ********************* Customize for environment

        

         e_mail = New MailMessage()

         e_mail.From = New MailAddress(txtFrom)

         e_mail.To.Add(txtTo)

         e_mail.Subject = txtSubject

         e_mail.IsBodyHtml = False

         e_mail.Body = txtMessage

         Smtp_Server.Send(e_mail)

        

         return true

        

      Catch error_t As Exception

         return false

      End Try

End function

https://www.tutorialspoint.com/vb.net/vb.net_send_email.htm

With expanded TO: lines

Function funSendMail(txtFrom As String, txtTo As String, txtSubject As String, txtMessage As String, bIsHTML As Boolean) As Boolean

        Try

            Dim Smtp_Server As New SmtpClient

            Dim e_mail As New MailMessage()

            Console.WriteLine("Sending to: " & txtTo)
          
            ' ********************* Customize for environment
            Smtp_Server.UseDefaultCredentials = True
            'Smtp_Server.Credentials = New Net.NetworkCredential("username@gmail.com", "password")
            Smtp_Server.Port = 25
            'Smtp_Server.EnableSsl = True
            Smtp_Server.Host = "mailserver.your.org"
            'Smtp_Server.Host = "smtp.gmail.com"
            ' ********************* Customize for environment
           e_mail = New MailMessage()
           e_mail.From = New MailAddress(txtFrom)

            For Each iEmail In Split(Replace(txtTo, ","";") & ";"";")
                If Len(iEmail) > 0 Then
                    e_mail.To.Add(Trim(iEmail))
                End If
            Next

'            For Each iEmail In Split(Replace(sDestinationEmailsBCC, ",", ";") & ";", ";")
                'If Len(iEmail) > 0 Then
                    'e_mail.Bcc.Add(Trim(iEmail))
                'End If

            'For Each iEmail In Split(Replace(sDestinationEmailsCC, ",", ";") & ";", ";")
                'If Len(iEmail) > 0 Then
                    'e_mail.cc.Add(Trim(iEmail))
                'End If

            'Next
            e_mail.Subject = txtSubject
            e_mail.IsBodyHtml = False
            e_mail.Body = txtMessage
            Smtp_Server.Send(e_mail)
           Return True

        Catch error_t As Exception
            Console.WriteLine(error_t.Message)
            Return False
        End Try
    End Function