Code for sending attachment as an email in PowerShell

Viewing 1 reply thread
  • Author
    Posts
    • #1557399
    • #1557416
      David Figueroa
      Participant
      Member Points: 4,096
      Rank: 3
      $MailParams = @{
        SMTPServer  = 'mail.domain.com'
        Port        = 25
        To          = 'user@domain.com'
        From        = 'someotheruser@domain.com'
        Body        = 'Here is my attachment'
        Attachments = 'c:\temp\attachment1.zip','c:\temp\test.txt'
        Subject     = 'Testing attachment capabilities'
       }
      Send-MailMessage @MailParams
      

      That’s pretty much it. The attachments just need to be an array of paths to the items.

       

      David F.

      avataravatar
Viewing 1 reply thread
  • You must be logged in to reply to this topic.
© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account