From f352d25b04310ba315d50dcfc4c44ccf0626893f Mon Sep 17 00:00:00 2001 From: Luc FULLENWARTH Date: Sun, 1 Jul 2018 20:47:31 +0200 Subject: [PATCH 1/3] Update community_snippets.md Added the Mail snippet --- docs/community_snippets.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/community_snippets.md b/docs/community_snippets.md index 855473939f..c7e308c56e 100644 --- a/docs/community_snippets.md +++ b/docs/community_snippets.md @@ -23,6 +23,7 @@ _To contribute, check out our [guide here](#contributing)._ | [DateTimeWriteVerbose](#datetimewriteverbose) | _Write-Verbose with the time and date pre-pended to your message by @ThmsRynr_ | | [Error-Terminating](#error-terminating) | _Create a full terminating error by @omniomi_ | | [IfShouldProcess](#ifshouldprocess) | _Added If Should Process_ | +| [Mail](#mail) | _Send an eMail with the most common parameters by @fullenw1_ | | [MaxColumnLengthinDataTable](#maxcolumnlengthindatatable) | _Gets the max length of string columns in datatables_ | | [Parameter-Credential](#parameter-credential) | _Add a standard credential parameter to your function by @omniomi_ | | [PesterTestForMandatoryParameter](#pestertestformandatoryparameter) | _Create Pester test for a mandatory parameter_ | @@ -191,6 +192,35 @@ Add If Should Process with easy tab inputs } ``` +### Mail + +Add the Send-MailMessage cmdlet with the most common parameters in a hashtable for splatting, by @ThmsRynr. + +#### Snippet + +```json +"Send-MailMessage": { + "prefix": "Send-MailMessage", + "body": [ + "$$Params = @{", + " 'SmtpServer' = 'smtp.mycompany.com'", + " 'Port' = 25", + " 'Priority' = 'Normal'", + " 'From' = 'sender@mycompany.com'", + " 'To' = 'mainrecipient@mycompany.com'", + " 'Cc' = 'copyrecipient@mycompany.com'", + " 'Bcc' = 'hiddenrecipient@mycompany.com'", + " 'Subject' = 'Mail title'", + " 'Body' = 'This is the content of my mail'", + " 'BodyAsHtml' = $$false", + " 'Attachments' = 'c:\\MyFile.txt'", + "}", + "Send-MailMessage @Params" + ], + "description": "Send a Mail" +} +``` + ### MaxColumnLengthinDataTable Takes a datatable object and iterates through it to get the max length of the string columns - useful for data loads into a SQL Server table with fixed column widths by @SQLDBAWithABeard From f39187b2ba653858dc70ef30641ff1e8a7a153be Mon Sep 17 00:00:00 2001 From: Luc FULLENWARTH Date: Sun, 1 Jul 2018 21:07:02 +0200 Subject: [PATCH 2/3] Update community_snippets.md Renamed the snippet --- docs/community_snippets.md | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/community_snippets.md b/docs/community_snippets.md index c7e308c56e..6181bd613e 100644 --- a/docs/community_snippets.md +++ b/docs/community_snippets.md @@ -23,13 +23,13 @@ _To contribute, check out our [guide here](#contributing)._ | [DateTimeWriteVerbose](#datetimewriteverbose) | _Write-Verbose with the time and date pre-pended to your message by @ThmsRynr_ | | [Error-Terminating](#error-terminating) | _Create a full terminating error by @omniomi_ | | [IfShouldProcess](#ifshouldprocess) | _Added If Should Process_ | -| [Mail](#mail) | _Send an eMail with the most common parameters by @fullenw1_ | | [MaxColumnLengthinDataTable](#maxcolumnlengthindatatable) | _Gets the max length of string columns in datatables_ | | [Parameter-Credential](#parameter-credential) | _Add a standard credential parameter to your function by @omniomi_ | | [PesterTestForMandatoryParameter](#pestertestformandatoryparameter) | _Create Pester test for a mandatory parameter_ | | [PesterTestForParameter](#pestertestforparameter) | _Create Pester test for parameter_ | | [PSCustomObject](#pscustomobject) | _A simple PSCustomObject by @brettmillerb_ | | [Region Block](#region-block) | _Region Block for organizing and folding of your code_ | +| [Send-MailMessage](#send-mailmessage) | _Send an mail message with the most common parameters by @fullenw1_ | ## Snippets @@ -192,35 +192,6 @@ Add If Should Process with easy tab inputs } ``` -### Mail - -Add the Send-MailMessage cmdlet with the most common parameters in a hashtable for splatting, by @ThmsRynr. - -#### Snippet - -```json -"Send-MailMessage": { - "prefix": "Send-MailMessage", - "body": [ - "$$Params = @{", - " 'SmtpServer' = 'smtp.mycompany.com'", - " 'Port' = 25", - " 'Priority' = 'Normal'", - " 'From' = 'sender@mycompany.com'", - " 'To' = 'mainrecipient@mycompany.com'", - " 'Cc' = 'copyrecipient@mycompany.com'", - " 'Bcc' = 'hiddenrecipient@mycompany.com'", - " 'Subject' = 'Mail title'", - " 'Body' = 'This is the content of my mail'", - " 'BodyAsHtml' = $$false", - " 'Attachments' = 'c:\\MyFile.txt'", - "}", - "Send-MailMessage @Params" - ], - "description": "Send a Mail" -} -``` - ### MaxColumnLengthinDataTable Takes a datatable object and iterates through it to get the max length of the string columns - useful for data loads into a SQL Server table with fixed column widths by @SQLDBAWithABeard @@ -342,6 +313,35 @@ Use the `#region` for organizing your code (including good code folding). } ``` +### Send-MailMessage + +Add the Send-MailMessage cmdlet with the most common parameters in a hashtable for splatting, by @fullenw1. + +#### Snippet + +```json +"Send-MailMessage": { + "prefix": "Send-MailMessage", + "body": [ + "$$Params = @{", + " 'SmtpServer' = 'smtp.mycompany.com'", + " 'Port' = 25", + " 'Priority' = 'Normal'", + " 'From' = 'sender@mycompany.com'", + " 'To' = 'mainrecipient@mycompany.com'", + " 'Cc' = 'copyrecipient@mycompany.com'", + " 'Bcc' = 'hiddenrecipient@mycompany.com'", + " 'Subject' = 'Mail title'", + " 'Body' = 'This is the content of my mail'", + " 'BodyAsHtml' = $$false", + " 'Attachments' = 'c:\\MyFile.txt'", + "}", + "Send-MailMessage @Params" + ], + "description": "Send a mail message" +} +``` + ## Contributing If you'd like to add a snippet to this list, [open a pull request](https://opensource.guide/how-to-contribute/#opening-a-pull-request) with the following changes: From 1f4e7af3ddb8f0a6828572a93e26439bc7b5811b Mon Sep 17 00:00:00 2001 From: Luc FULLENWARTH Date: Mon, 2 Jul 2018 13:28:46 +0000 Subject: [PATCH 3/3] Update community_snippets.md Snippet renamed to ex-Send-MailMessage which stands for "example of Send-MailMessage" --- docs/community_snippets.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/community_snippets.md b/docs/community_snippets.md index 6181bd613e..a1d9864e1f 100644 --- a/docs/community_snippets.md +++ b/docs/community_snippets.md @@ -320,8 +320,8 @@ Add the Send-MailMessage cmdlet with the most common parameters in a hashtable f #### Snippet ```json -"Send-MailMessage": { - "prefix": "Send-MailMessage", +"ex-Send-MailMessage": { + "prefix": "ex-Send-MailMessage", "body": [ "$$Params = @{", " 'SmtpServer' = 'smtp.mycompany.com'",