none
David Wyatt's SendMailMessage Script Not working

    Question

  • https://gallery.technet.microsoft.com/scriptcenter/Send-MailMessage-3a920a6d#content

    I wish it was throwing an error, but its not.  I downloaded his SendMailMessage.ps1 and then used his example to develop the following code:

    $images = @{

    image1 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image001.png' image2 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image002.png' image3 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image003.png' image4 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image004.png' image5 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image005.png' image6 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image006.png' image7 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image007.png' image8 = '\\portal2010.Brand.com\sites\Brand HC\Brand HC Dashboards\2017 JE Headcount_files\2017 Brand Headcount_25311_image008.png' } $body = @' <html> <body> <img src="cid:image1"><br> <img src="cid:image2"><br> <img src="cid:image3"><br> <img src="cid:image4"><br> <img src="cid:image5"><br> <img src="cid:image6"><br> <img src="cid:image7"><br> <img src="cid:image8"><br> </body> </html> '@ $params = @{ InlineAttachments = $images Body = $body BodyAsHtml = $true Subject = 'Test' From = 'Snoopy <Snoopy@Brand.com>' To = 'Linus <Linus@Brand.com>' SmtpServer = 'smtp.Brand.com' Port = 25 UseSsl = $false } .\Send-MailMessage.ps1 @params

    I run the above code and get no errors as mentioned, but I also never get an email.

    I have change UseSsl to true and that doesn't change anything. I have also removed it altogether.

    How can I figure out why its not sending an email?




    Monday, March 20, 2017 1:36 PM

All replies

  • Hi J,

    that's because the script you are linking is a function-script. It adds a tool, rather than running some code.

    Use it like this:

    . .\Send-MailMessage.ps1
    Send-MailMessage @params

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Monday, March 20, 2017 2:20 PM
  • Can you send an email using Send-MailMessage and receive it?

    -- Bill Stewart [Bill_Stewart]

    Monday, March 20, 2017 2:23 PM
    Moderator