Skip to content

Commit f54a611

Browse files
fullenw1TylerLeonhardt
authored andcommitted
Update community_snippets.md (#1395)
* Update community_snippets.md Added the Mail snippet * Update community_snippets.md Renamed the snippet * Update community_snippets.md Snippet renamed to ex-Send-MailMessage which stands for "example of Send-MailMessage"
1 parent 705f174 commit f54a611

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/community_snippets.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ _To contribute, check out our [guide here](#contributing)._
2929
| [PesterTestForParameter](#pestertestforparameter) | _Create Pester test for parameter_ |
3030
| [PSCustomObject](#pscustomobject) | _A simple PSCustomObject by @brettmillerb_ |
3131
| [Region Block](#region-block) | _Region Block for organizing and folding of your code_ |
32+
| [Send-MailMessage](#send-mailmessage) | _Send an mail message with the most common parameters by @fullenw1_ |
3233

3334
## Snippets
3435

@@ -312,6 +313,35 @@ Use the `#region` for organizing your code (including good code folding).
312313
}
313314
```
314315

316+
### Send-MailMessage
317+
318+
Add the Send-MailMessage cmdlet with the most common parameters in a hashtable for splatting, by @fullenw1.
319+
320+
#### Snippet
321+
322+
```json
323+
"ex-Send-MailMessage": {
324+
"prefix": "ex-Send-MailMessage",
325+
"body": [
326+
"$$Params = @{",
327+
" 'SmtpServer' = 'smtp.mycompany.com'",
328+
" 'Port' = 25",
329+
" 'Priority' = 'Normal'",
330+
" 'From' = 'sender@mycompany.com'",
331+
" 'To' = 'mainrecipient@mycompany.com'",
332+
" 'Cc' = 'copyrecipient@mycompany.com'",
333+
" 'Bcc' = 'hiddenrecipient@mycompany.com'",
334+
" 'Subject' = 'Mail title'",
335+
" 'Body' = 'This is the content of my mail'",
336+
" 'BodyAsHtml' = $$false",
337+
" 'Attachments' = 'c:\\MyFile.txt'",
338+
"}",
339+
"Send-MailMessage @Params"
340+
],
341+
"description": "Send a mail message"
342+
}
343+
```
344+
315345
## Contributing
316346

317347
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:

0 commit comments

Comments
 (0)