Try the code here:

   1.
   
https://support.automatedresults.net/KB/a86/powershell-script-to-send-email-with-attachment.aspx
   2.
   
http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_26692445.html


--
ME2






On Sat, Feb 26, 2011 at 8:53 AM, Matthew Bullock <[email protected]> wrote:



>  Hi Michael, thanks  for the reply.  Unfortunately that didn’t change
> anything.  A friend of mine who is a .Net dev said something about adding
> the attachment to the message but I cant seem to figure out the right
> statement.  From what I’ve read, it should be something like
> $messageParameters.Attachment.Add(“$Attachment”) but it just throws an
> error.
>
>
>
> -matt
>
>
>
> *From:* Micheal Espinola Jr [mailto:[email protected]]
> *Sent:* Friday, February 25, 2011 6:16 PM
> *To:* NT System Admin Issues
> *Subject:* Re: PS send email w/ embedded image
>
>
>
> Could be because the header for MediaType should be "image/jpeg" ?
>
> --
>
>
>
>
>
> ME2
>
>
>
>
>
>
>
>
> On Fri, Feb 25, 2011 at 5:47 PM, Matthew Bullock <[email protected]>
> wrote:
>
> I was  hoping someone might be able to help me out with a poweshell
> script.  The script sends a simple email, but I’m trying to embed a logo
> image and it’s not working.  All I get is an empty square for the image.
>
>
>
> Any help would be much appreciated,
>
>
>
> -matt
>
>
>
>
>
> $Attachment = New-Object System.Net.Mail.Attachment("C:\scripts\logo.jpg")
>
> $Attachment.ContentDisposition.Inline = $True
>
> $Attachment.ContentDisposition.DispositionType = "Inline"
>
> $Attachment.ContentType.MediaType = "image/jpg"
>
> $Attachment.ContentId = "logo"
>
>
>
>
>
> $body = {
>
>                 <html xmlns:o="urn:schemas-microsoft-com:office:office"
> xmlns:v="urn:schemas-microsoft-com:vml">
>
>     <head>
>
>       <style type='text/css'>
>
>         BottomRight {
>
>           position: absolute;
>
>           bottom: 2px;
>
>           right: 4px;
>
>         }
>
>       </style>
>
>     </head>
>
>     <body>
>
>                                 <font face="calibri, helvetica" size="2">
>
>                                 <p>Hello</p>
>
>                                 </font>
>
>                                 <div id='BottomRight'>
>
>                                                 <img src='cid:logo
> alt=logo'/>
>
>                                 </div>
>
>     </body>
>
>   </html>
>
> }
>
> $messageParameters = @{
>
>                                 From = "[email protected]”
>
>                                 To = "[email protected]”
>
>                                 SmtpServer = “mxserver"
>
>                                 Subject = "Test Email"
>
>                                 Body = $body
>
>                                 }
>
> Send-MailMessage @messageParameters -BodyAsHtml
>
> $Attachment.Dispose()
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to [email protected]
> with the body: unsubscribe ntsysadmin
>
>
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to [email protected]
> with the body: unsubscribe ntsysadmin
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to [email protected]
> with the body: unsubscribe ntsysadmin
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to