Hi can we get confirmation for sending mails in send-mailmessage, i tried it with $lastexitcode but it works only on ISE not in console, is there any other way of doing it?, basically i want to check whether the mail has been sent successfully
Technology Tips and News
Hi can we get confirmation for sending mails in send-mailmessage, i tried it with $lastexitcode but it works only on ISE not in console, is there any other way of doing it?, basically i want to check whether the mail has been sent successfully
Have the user reply to your message.
Of course you could take the lazy approach and read the help but that wouldn't be any fun.
Help Send-MailMessage -Full
Send-MailMessage -DeliveryNotificationOption OnSuccess
$mailparam = @{ FROm = '<Address>' To = '<Address>' SMTP = '<SMTP>' SUBJECT = 'Test Mail for - Mail Delivery Notification' } Send-MailMessage @mailparam -DeliveryNotificationOption OnSuccess
This didnt solve my issue, as my qn was different. i have fixed it myself by $?
So you are saying that you asked the wrong question. Your question should have been how doo you detect an error has occurred in the send process and not how do you validate delivery. No error does not mean the mail was delivered. It only means that Send-MailMessage was able to hand the mail item to YOUR sending smtp server. This has nothing to do with mail "delivery".
Mail "confirmation" is a technical term that has nothing to do with errors in processing. "$?" signal that no system errors have occurred.
How SMTP mail system work is an important technology for an Admin to know well. I recommend that you spend some time studying this ooften used technology as you will need it frequently.