Send-MailMessage

Glenn Maxwell 10,146 Reputation points
2024-04-30T22:09:49.3733333+00:00

Hi All

I am using exchange 2016 hybrid environment. i am trying to trigger test email from exchange PowerShell using the below syntax but i am unable to. Please guide me with the syntax. 192.168.1.10 is my onprem exchange server.

1..10 | %{Send-MailMessage -from "test@mydomain.com -to "user1@mydomain.com" -port 25 -subject Get-Date -Format "yyyy-MM-dd HH:mm:ss.fff" -SmtpServer 192.168.1.10}

Exchange Server
Exchange Server
A family of Microsoft client/server messaging and collaboration software.
1,103 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,238 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,386 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 98,606 Reputation points MVP
    2024-04-30T22:27:32.7333333+00:00

    Hi @Glenn Maxwell ,

    what does "I am unable to" mean? Any error messages?

    You can try this please:

    $From = "test@mydomain.com"
    $To = "user1@mydomain.com"
    $SMTPServer = "192.168.1.10"
    $Body = "This is a test email."
    for ($i = 1; $i -le 10; $i++) {
        $Subject = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss.fff")
        Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Port 25
        Write-Output "Email $i sent."
    }
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten

    0 comments No comments