Thursday, December 8, 2016

PowerShell - Send Test Email (Office 365) Using PowerShell


Here is a sample PowerShell script which can be to test email communication using a SMTP server. In this script, I am using Office 365 SMTP server,








$SMTPServer = ""

$EmailFrom = ""

$EmailTo = ""


#Send-MailMessage Reference -




Write-Host "`t`tSelect 1 - SMTP Test Message with No Attachmnet" -ForegroundColor Red

Write-Host "`t`tSelect 2 - SMTP Test Message" -ForegroundColor Red

$Option = Read-Host




Function EmailTest_No_Attachment


#with no attachement


$Cred = Get-Credential

$Sub = "SMTP Test Message - 1 - No Attachmnet"

$Bmessage = "SMTP Test Message - 1 with Attachment"

Send-MailMessage -From $EmailFrom -To $EmailTo -Subject $Sub -Body $Bmessage -SmtpServer $SMTPServer -Credential $cred -UseSsl -Port 587



Function EmailTest_With_Attachment


#with Attachment


$Cred = Get-Credential

$Sub = "SMTP Test Message - 1 with Attachment"

$Bmessage = "Test email body message - With Attachment"

$MyAttachment =  "C:\temp\1.docx"

Send-MailMessage -From $EmailFrom -To $EmailTo -Subject $Sub -Body $Bmessage -Attachments $MyAttachment -SmtpServer $SMTPServer -Credential $cred -UseSsl -Port 587






Switch ($Option)


        1 {EmailTest_No_Attachment}

        2 {EmailTest_With_Attachment}

    default {"Invalid Selection"}



Script download options:

1.        OneDrive -!AuVEEHIwTxv9h4ZXLslcu1MzA8ZSqw

2.       TechNet Gallery -!AuVEEHIwTxv9h4ZXLslcu1MzA8ZSqw




You can also read more great articles on this topic at this website, guys.

Hello! I just read this information and i can tell you that this article is useful. Thank you for sharing it. And look at this -

I got 5 on it, let’s go half on a sack this source

Very useful information, especially for those who are just starting programming. Students will find a lot of interesting things. I, in turn, want to recommend a great site. Here you can find information on how to write an essay or term paper customessaymeister

This means you have to let go of your judgement about what is right and what is wrong and keep your eyes open for what can help. It could be something simple, like a kid wanting to talk to you about their day, or something huge like an invitation to a conference with like-minded people. Stay open and you are guaranteed to surpass other people who are close-minded .

If you are decisive about placing an order at writing elites, you can always ask questions or share your concerns with its customer support representatives. Its pleasant, polite customer service staff works 24/7 to give you an immediate answer.

If you are supposed to complete a creative and original PPT Poster in agreement with the requirements set and the deadline indicated, but you consider that you will not handle it in a decent way, why not buy ppt from our trustworthy academic writing company.

Hello, thanks for sharing this interesting information I appreciate reading it. It's great that I found this post. It will help me with my computing skills. Moreover, I will use the information in my top quality essay provider. Thanks a lot.

This comment has been removed by the author.

Event management assignment writing services are essential and they have become very popular for those seeking event management essay writing help services since most of them seek Event Management Writing Services.

The point of a laboratory report is to conduct an experiment, develop a hypothesis, and do research to support their claims. You also need to do precise calculations, collect data, analyze the results, and express it in a way that will be understandable to the reader. lab report writing service

Seeking for the Physics Assignment Help ? If yes then have a look here.

Math may be considered a difficult subject, however, if you are thinking of making a career in this subject you know it is also interesting and has the potential to place you in the best companies and organizations. With a constant urge of performing well on exams and tests and homework and assignments, you may be feeling fatigued. It is better to take help from a renowned online service provider like Help in Homework. Our experts at Help in Homework provide top notch math assignment help to students and help them fetch the prestigious A grade at a very affordable rate. Our experts are specialized in the subject and accommodate your instructions and keep the assignment 100% plagiarism-free.

Use Finance assignment help to finish your finance or accounting papers without messing yourself. You will get assured solutions to your numerical questions within your defined date or time.

Do you also want to take online Assignment help? Then don’t worry, we will help you! We offer you the best assignment writing services at a very low price. Browse our website for taking the best assignment writing help.

Hard exams, assignments and homework are a now things of the past with Test Bank For Anatomy And Physiology 9th Edition. Order and download now!

Post a Comment

Popular Posts


Twitter Delicious Facebook Digg Stumbleupon Favorites More