'Sending email with attachment using Cygwin email package

I installed cygwin together with this package: https://cygwin.com/packages/x86_64/email/email-3.2.1-git-1

Do you know how to create a bat file and send email with attachment using cygwin email package in windows 10?



Solution 1:[1]

Powershell is builtin to your windows device,powershell 2.0 and up has the Send-MailMessage function. If you really need to use batch-file for this task, you can simply call powershell from within a batch-file:

@echo off
powershell Send-MailMessage -From '[email protected]' -To '[email protected]' -Subject 'Test email' -Body 'This is a test' -SmtpServer mailserver.domain.com -Attachments 'C:\Some Dir\Somefile.txt'

to break it down into a readable form on Stackoverlow:

powershell Send-MailMessage 
      -From '[email protected]'
      -To '[email protected]'
      -Subject 'Test email'
      -Body 'This is a test'
      -SmtpServer mailserver.domain.com
      -Attachments 'C:\Some Dir\Somefile.txt'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gerhard