Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to send-mailmessage from displayname?

I would like to know how do you send mailmessage from displayname? I think we should add New-Object System.Net.Mail.MailMessage to the script but im not sure how to do it..?

$Mail = @{             
                    'To'         = 'someone@domain.com'
                    'From'       = 'me@domain.com','Lastname, Firstname' #I dont know what to do here
                    'Subject'    = "TEST NOTIFICATION"
                    'SMTPServer' = 'mail.domain.com'
                    'Encoding'   = 'UTF8'
                    'Priority'   = 'High'
                    'Body'       = "Hi, this is a test"
}

Send-MailMessage @Mail

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Use the following format: Display Name <sender-address>:

$Mail = @{             
    'To'         = 'someone@domain.com'
    'From'       = 'Lastname, Firstname <me@domain.com>'
    'Subject'    = "TEST NOTIFICATION"
    'SMTPServer' = 'mail.domain.com'
    'Encoding'   = 'UTF8'
    'Priority'   = 'High'
    'Body'       = "Hi, this is a test"
}

Send-MailMessage @Mail
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading