Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5836485

Browse files
fullenw1Robert Holt
authored and
Robert Holt
committed
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 eae5727 commit 5836485

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)

AltStyle によって変換されたページ (->オリジナル) /