• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1012
  • Last Modified:

Powershell - Send-MailMessage - hide attachment

Hello,

Pls would you advice? Is it possible to hide attached file(*.xlsx)?

 
Send-MailMessage -From "xx" -To "yyy" -Smtpserver "server" -Subject "REPORT: " -BodyAsHtml  -Body $Body -Attachments "C:\b\x.csv","C:\b\y.csv"  -Credential $mycreds

Open in new window


I mean that if somebody gets that email this attachment wont be visible.

Many thanks
0
Radim88
Asked:
Radim88
  • 2
1 Solution
 
Chris DentPowerShell DeveloperCommented:
Whatever happens to attachments is down to the mail client, and even then, hiding something other than images in-line will be very challenging / perhaps not possible.

Images are done using System.Net.MailMessage (I'm afraid Send-MailMessage won't help you, you have to go down into .NET). This example is in C#, but there's little practical difference:

http://blog.devexperience.net/en/12/Send_an_Email_in_CSharp_with_Inline_attachments.aspx

Or:

http://kosiara87.blogspot.com/2011/04/c-sending-mail-with-embedded-image.html

I don't mind helping you convert the code, but I'm not convinced they'll do what you want them to.

Chris
0
 
Radim88Author Commented:
Pls if you can do that.
0
 
Radim88Author Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now