Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update community_snippets.md #1395

Merged
merged 3 commits into from
Jul 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update community_snippets.md
Added the Mail snippet
  • Loading branch information
fullenw1 authored Jul 1, 2018
commit f352d25b04310ba315d50dcfc4c44ccf0626893f
30 changes: 30 additions & 0 deletions docs/community_snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_ |
Expand Down Expand Up @@ -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
Expand Down