r/PowerShell • • Apr 12 '19

Meet Emailimo - Easy way to send pretty emails

Hello ;-) It's me again.

Today I wanted to present a little PowerShell module that makes it easy to send emails. Full overview with examples can be found https://evotec.xyz/meet-emailimo-new-way-to-send-pretty-emails-with-powershell/

What is it about? It's supposed to make it clearly visible what you're trying to send with Powershell so that when you look back at your code in 6 months time you know what is going on and you can fix any formatting as you want it.

Import-Module PSWriteHTML -Force
Import-Module Emailimo -Force
### Prepare your data:
$UserNotify = 'Przemysław Kłys'
$PasswordExpiryDays = 5
Email -WhatIf {
    EmailHeader {
        EmailFrom -Address '[email protected]'
        EmailTo -Addresses "[email protected]"
        EmailServer -Server 'mail.evotec.com' -UserName 'YourUsername' -Password 'C:\Support\Important\Password-Evotec-Reminder.txt' -PasswordAsSecure -PasswordFromFile
        EmailOptions -Priority High -DeliveryNotifications Never
        EmailSubject -Subject 'This is a test email'
    }
    EmailBody -FontFamily 'Calibri' -Size 15 {
        EmailTextBox {
            "Hello $UserNotify,"
            ""
            "Your password is due to expire in $PasswordExpiryDays days."
            ""
            'To change your password: '
            '- press CTRL+ALT+DEL -> Change a password...'
            ''
            'If you have forgotten your password and need to reset it, you can do this by clicking here. '
            "In case of problems please contact the HelpDesk by visiting [Evotec Website](https://evotec.xyz) or by sending an email to Help Desk."
            ''
            'Alternatively you can always call Help Desk at +48 22 00 00 00'
            ''
            'Kind regards,'
            'Evotec IT'
        }
        EmailText -LineBreak
    }

Example 2:

Import-Module PSWriteHTML -Force
Import-Module Emailimo -Force
### Prepare your data:
$UserNotify = 'Przemysław Kłys'
$PasswordExpiryDays = 5
Email {
    EmailHeader {
        EmailFrom -Address '[email protected]'
        EmailTo -Addresses "[email protected]"
        EmailServer -Server 'mail.evotec.com' -UserName 'UserName' -Password 'C:\Support\Important\Password-Evotec-Reminder.txt' -PasswordAsSecure -PasswordFromFile
        EmailOptions -Priority High -DeliveryNotifications Never
        EmailSubject -Subject 'This is a test email'
    }
    EmailBody -FontFamily 'Calibri' -Size 15 {
        EmailText -Text "Hello ", $UserNotify, "," -Color None, Blue, None -Verbose -LineBreak
        EmailText -Text "Your password is due to expire in ", $PasswordExpiryDays, "days." -Color None, Green, None
        EmailText -LineBreak
        EmailText -Text 'To change your password: '
        EmailText -Text '- press ', 'CTRL+ALT+DEL', ' -> ', 'Change a password...' -Color None, BlueViolet, None, Red
        EmailText -LineBreak
        EmailTextBox {
            'If you have forgotten your password and need to reset it, you can do this by clicking here. '
            "In case of problems please contact the HelpDesk by visiting [Evotec Website](https://evotec.xyz) or by sending an email to Help Desk."
        }
        EmailText -LineBreak
        EmailText -Text 'Alternatively you can always call ', 'Help Desk', ' at ', '+48 22 00 00 00' `
            -Color None, LightSkyBlue, None, LightSkyBlue -TextDecoration none, underline, none, underline -FontWeight normal, bold, normal, bold
        EmailText -LineBreak
        EmailTextBox {
            'Kind regards,'
            'Evotec IT'
        }
    }
}

Here's couple of screenshots. Hopefully those show up on Reddit. If not, go for the link :-)

169 Upvotes

26 comments sorted by

20

u/WadeEffingWilson Apr 12 '19

"And I was like 'Emailimoooooooo'."

2

u/MadBoyEvo Apr 12 '19

ye, it's a bit tricky to say it. But you know the name is actually Email + IMO where IMO = I made one. Same as Dash + IMO or Status IMO. Simple branding but I was a bit tired with my standard naming PSWinDocumentation, PSWinReporting and so on :-)

9

u/WadeEffingWilson Apr 12 '19

I was being silly. It reminded me of that part on Night at the Roxbury where they are telling the story of seeing Emilio Estevez.

Very impressive work, though.

3

u/MaxHedrome Apr 12 '19

Oh god..... this joke deserves an internet medal made of blow jobs

2

u/NoonsReport Apr 13 '19

The mighty duck man himself!

1

u/orwiad10 Apr 12 '19

You lost your partner today.  What’s his name?  Emilio?  Emilio is going to prison.

4

u/TwistedTsero Apr 12 '19

This is cool. Guess its time to pretty up some of my reports that send blandly formatted data/tables in emails.

2

u/MadBoyEvo Apr 12 '19

Let me know if you will 'miss' something. I would like to know what people use, what doesn't make sense and what's missing.

3

u/Frndlyy Apr 12 '19

You are one hell of a Mad Boy Evo!!! Great work and thank you for sharing. 👌❤️❤️❤️

4

u/MadBoyEvo Apr 12 '19

Enjoy :-)

16

u/3369fc810ac9 Apr 12 '19

1000 upvotes for including screenshots.

1

u/Thingsthatdostuff Apr 12 '19

So that's the number i call for help? Just kidding. Great job!

2

u/MadBoyEvo Apr 12 '19

I doubt anyone will pick up, it's made up number. I can give my private number as long as you're willing to pay for my services :-)

1

u/riceadd1ct Jul 19 '19

PoSh Novice looking for a helping hand...

Created a script following Example 2 (roughly) and it "runs" but I don't receive an email.

At the end of the test script, do I need to run Send-MailMessage and input the info from the Email command, or am I missing something else here?

Link to the script

1

u/MadBoyEvo Jul 19 '19

Set for Email parameter Supress to false. It will return message from send mail and based on that you will know where it fails. Its all builtin but hidden when Supress is True (default)

If I had to guess you need to enable SSL, i think default is disabled.

3

u/[deleted] Apr 12 '19

I actually can use this right away! Thanks!

1

u/ReelAwesome Apr 12 '19

Found an upgrade for half of my slack/email job reporter. This is fucking fantastic. Thanks a ton internet friend!

-4

u/yutsoku Apr 12 '19

I'll stick with .html templates that I can custom design

5

u/MadBoyEvo Apr 12 '19

Sure, if you know how to work with HTML that's easiest. This isn't for you ;-)

0

u/[deleted] Apr 13 '19

[deleted]

1

u/MadBoyEvo Apr 13 '19

As explained on another Reddit, if you're fine with what you get from Outlook HTML I'm ok with it. From my experience, it only works to some extent. But feel free to create a proper post, maybe a blog how would you create dynamic reports in Email. Those that do change depending on circumstances. Let's compare our results ;-)

0

u/[deleted] Apr 12 '19

[deleted]

2

u/MadBoyEvo Apr 12 '19

Not sure how it's related. Can you explain?

1

u/lavahot Apr 12 '19

I'm thinking he responded to the wrong thread.

1

u/admiralspark Apr 12 '19

God damnit, yep, sorry /u/MadBoyEvo

1

u/MadBoyEvo Apr 12 '19

No problem :)

0

u/[deleted] Apr 12 '19

[deleted]

1

u/MadBoyEvo Apr 12 '19

To be honest there's no deep reason. I have PSWriteHTML which follows that verb-noun. In here it would most likely crash with some other module New-Email, New-EmailHeader, New-EmailText. It's good practice but it's not banned so why not? Pester does this, PSScribo does this and few more do this.

-4

u/[deleted] Apr 12 '19

It’d be trivial to fix that. Move on.