Home > Software engineering >  Sending email with attachment using Cygwin email package
Sending email with attachment using Cygwin email package

Time:04-21

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?

CodePudding user response:

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'
  • Related