• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1007
  • 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

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

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